yeshan333

yeshan333

How to install multiple versions of Erlang and Elixir with vfox

vfox (version-fox) is a popular general version management tool write in Go, and the plug-in mechanism uses Lua to achieve extensibility. At present, vfox has supported the management of most mainstream programming language versions, and the ecosystem is quite strong. Here you can see the programming language versions and tools that vfox currently supports and manages → vfox-Available Plugins.

The Elixir and Erlang communities have long been popular for installing and managing multi-version environments through asdf. asdf is also a general-purpose version management tool, and the ecosystem is so rich.

Vfox is very similar to asdf-vm in that it uses .tool-versions file to manage project-level and global version information. This means that if you’ve used asdf before, it won’t be difficult to switch to vfox. Because the core implementations of vfox and vfox are a bit different, vfox executes nearly 5 times faster than ASDF~, and the official documentation also gives benchmark results: version-fox Comparison with asdf-vm

https://vfox.lhan.me/performence.png

If you’ve been using asdf to manage and maintain multiple versions of Erlang and Elixir, then vfox is also a good choice for you.

This article will show you how to install and manage multiple versions of Erlang and Elixir via vfox.

Install vfox

vfox (version-fox) is cross OS system friendly, which means it can be used on both Windows and Unix-like systems. The core of this article is to install and manage multiple versions of Erlang and Elixir through vfox. Because the two plug-in implementations of vfox to manage Erlang and Elixir versions do not yet support management under the Windows operating system, the sample environment in this article is mainly the Ubuntu 20.04 Linux environment. Let’s get started~

Install vfox (version fox) first:


echo "deb [trusted=yes] https://apt.fury.io/versionfox/ /" | sudo tee /etc/apt/sources.list.d/versionfox.list

sudo apt-get update

sudo apt-get install vfox

In order for vfox to find the installed versions of Elixir and Erlang, vfox needs to be mounted to the shell by default. Next, modify the shell configuration (take Bash as an example):


# Hook your shell

echo 'eval "$(vfox activate bash)"' >> ~/.bashrc

You can also refer to this official documentation to install vfox → https://vfox.lhan.me/guides/quick-start.html. After installing VFOX, let’s install the following plugins:


# add vfox-erlang plugin

vfox add erlang

# add vfox-elixir plugin

vfox add elixir

Next, we can install and manage multiple versions of Erlang and Elixir through the two vfox plugins vfox-erlang and vfox-elixir installed above.

Install Erlang/OTP via the vfox-erlang plugin

Because Elixir depends on Erlang, we need to install Erlang before installing Elixir. Erlang is installed through the source code of the corresponding version, so we need to have the corresponding compilation toolchain, here take Ubuntu 20.04 as an example:


sudo apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk

Now it’s time to install Erlang.


# use vfox search get an avaliable version

❯ vfox search erlang

Please select a version of erlang [type to search]:

-> v25.0.4

v24.3.4.16

v24.1.3

v24.0

v24.3

v24.3.2

v25.2

v27.0-rc2

v24.3.4.1

Press ↑/↓ to select and press ←/→ to page, and press Enter to confirm

# you can also specific a version, eg:

vfox install erlang@26.2.2

Theoretically, you could install any version that appears in https://github.com/erlang/otp/releases. Since it is compiled and installed from source, the installation process will take some time. When you see the following message, the installation is complete.


compile info.......

...

Install erlang@26.2.2 success!

Please use vfox use erlang@26.2.2 to use it.

Let’s use vfox to switch to the Erlang/OTP version we just installed to verify that the installation is successful:


❯ vfox use erlang@26.2.2

Now using erlang@26.2.2.

❯ erl

Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.2.2 (press Ctrl+G to abort, type help(). for help)

1>

If the REPL wakes up correctly, then install it. Let’s start installing Elixir.

Install Elixir

Because the installation of Elixir is also compiled and installed from the source code of the corresponding version, the compilation of Elixir needs to depend on Erlang, so we first let the current shell can find the Erlang just installed.


# switch shell to a Erlang version

❯ vfox use erlang@26.2.2

Now using erlang@26.2.2.

# install Elixir

> vfox install elixir@1.15.2

.........

.........

Generated ex_unit app

==> logger (compile)

Generated logger app

Generated eex app

==> iex (compile)

Generated iex app

Install elixir@1.15.2 success!

Please use vfox use elixir@1.15.2 to use it.

When you see Install elixir@1.15.2 success!, it means that the installation has been successful. The installation can be confirmed by IEX as a complete success:


❯ vfox use elixir@1.15.2

Now using elixir@1.15.2.

❯ iex

Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.15.2) - press Ctrl+C to exit (type h() ENTER for help)

iex(1)>

If you want to install a different version of Elixir, please make sure that the current version of Erlang/OTP is compatible with the version of Elixir, check this document to confirm compatibility: 《compatibility-and-deprecations.html#between-elixir-and-erlang-otp》

Set the global usage version

We can use vfox use -g xxx to set the version of Erlang and Elixir that we use by default.


> vfox use -g erlang@26.2.2

> vfox use -g elixir@1.15.2

# make sure setting succ

> cat ~/.version-fox/.tool-versions

erlang 26.2.2

elixir 1.15.2

The End

The two plugins for vfox to install and manage the Erlang/OTP and Elixir versions also support managing multiple versions under MacOS Darwin System. You can check out this document for more information: https://github.com/version-fox/vfox-elixir?tab=readme-ov-file#install-in-darwin-macos-13.

Happy & funny!

Most Liked

dimitarvp

dimitarvp

This is pretty nice, thanks for posting. I feel there really should have been a comparison with mise however, which is much faster than asdf and is fully compatible with its plugins.

dimitarvp

dimitarvp

It’s not only that it’s written in Rust (to me that’s an advantage as well). It’s that it doesn’t use shims and only manipulates $PATH instead, which removes overhead when starting any tool managed by it. (And asdf uses shims.)

Where Next?

Popular in Guides/Tuts Top

zenw0lf
Hello all! For those wanting to try your hands at Elixir / Phoenix, I wrote a comprehensive tutorial on doing a simple JSON API with sai...
New
Logan
Here is an example of a Mix application that utilizes Cowboy to handle websocket connections. If anyone has an idea about making this wor...
New
ben-pr-p
https://github.com/ben-pr-p/elixir-phoenix-parcel-example Hey all! I put together a starter-pack / instructions to set up Phoenix with t...
New
stryrckt
I’m excited about the new LiveComponents feature in LiveView, but I haven’t seen much written on it, so I decided to write a couple of ar...
New
f0rest8
Hi, TLDR: form attribute set on the input fields and button submit. I just wanted to share a solution I discovered when making live inl...
New
emilsoman
Hello, While answering a StackOverflow question on how to debug an elixir node running remotely, I thought it may be helpful to write a ...
New
zazaian
I recently generated the boilerplate for a new mix app using the Phoenix 1.3.1 phx.new generator and realized that the structure of the w...
New
jtormey
Hello! Having written a lot of LiveView code, I’ve made some VS Code snippets to speed up writing callbacks for LiveViews and LiveCompon...
New
TwistingTwists
This is a thread to note down things/best practices encountered in LiveBeats App as I explore the source code. https://github.com/fly-...
New
smpallen99
Some advice for Elixir programmers. I was reviewing someone’s Elixir Code yesterday and found a deadlock condition bug in a GenServer im...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement