DEV Community

Cover image for (Amazing!) How to manage and install multiple versions of Erlang/OTP and Elixir via vfox in Windows
yeshan333
yeshan333

Posted on

(Amazing!) How to manage and install multiple versions of Erlang/OTP and Elixir via vfox in Windows

About a month ago, I wrote an article on how to use the cross-platform version management tool vfox to install and manage multiple Erlang/OTP and Elixir version under Linux system -> Install mutiple Erlang and Elixir with vfox. the demonstration operation system used in the article is Ubuntu 20.04 Linux operation system.

Recently, the latest version of the vfox-erlang and vfox-elixir plugins has supported the installation and management of multiple version of Erlang/OTP and Elixir under Windows platforms. and has passed the End to End test -> Testing.

E2E testing

This article will use the Windows 10 operation system as an example to teach you how to install and manage multiple Erlang/OTP and Elixir version on Windows platforms.

> Get-ComputerInfo
WindowsBuildLabEx                                       : 22621.1.amd64fre.ni_release.220506-1250
WindowsCurrentVersion                                   : 6.3
WindowsInstallationType                                 : Client
WindowsProductName                                      : Windows 10 Pro
......
Enter fullscreen mode Exit fullscreen mode

1、Install vfox

vfox (version-fox) is a popular cross-platform universal version management tool recently. it is written in Go language and the plug-in mechanism uses Lua to realize scalability. currently vfox already supports the management of versions of most mainstream programming languages, and the ecosystem is relatively strong. here you can see the programming language versions and tools currently supported and managed by vfox-> vfox-Available Plugins.

Please be sure to install vfox of version 0.5.3+ and above, otherwise vfox-erlang and vfox-elixir will not work normally. Here we install vfox through winget:

> winget install vfox
.......

❯ vfox -version
vfox version 0.5.3
Enter fullscreen mode Exit fullscreen mode

In order for vfox to find the installed versions of Elixir and Erlang, vfox needs to be mounted to the powershell by default:

if (-not (Test-Path -Path $PROFILE)) { New-Item -Type File -Path $PROFILE -Force }; Add-Content -Path $PROFILE -Value 'Invoke-Expression "$(vfox activate pwsh)"'
Enter fullscreen mode Exit fullscreen mode

If PowerShell prompts: cannot be loaded because the execution of scripts is disabled on this system.Open PowerShell with Run as Administrator.Then, run this command in PowerShell

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# After that type Y and press Enter.
y
Enter fullscreen mode Exit fullscreen mode

You can also refer to the official document to install vfox -> https://vfox.lhan.me/guides/quick-start.html. after installing vfox, we will install the following version management plugins:

# add vfox-erlang plugin for managine mutiple erlang versions
vfox add erlang
# add vfox-elixir plugin for managine mutiple elixir versions
vfox add elixir
Enter fullscreen mode Exit fullscreen mode

After the installation is complete, you can use the two vfox plugins vfox-erlang and vfox-elixir in the Windows platform to install and manage multiple Erlang and Elixir versions.

Let's continue.

2、Install Erlang/OTP through vfox-erlang plugin

Since Elixir relies on Erlang/OTP, we need to install Erlang/OTP before installing Elixir. If you have already installed Erlang/OTP through other methods, please ensure that the version of Elixir installed through vfox-elixir is compatible with it. You can check the official documentation of Elixir to confirm this between-elixir-and-erlang-otp.

# get 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 specify a version to install, such as
vfox install erlang@26.2.2
Enter fullscreen mode Exit fullscreen mode

you can install any distribution that appears in the https://github.com/erlang/otp/releases containing the windows executable(exe) file. 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.
Enter fullscreen mode Exit fullscreen mode

We use vfox to switch to the Erlang/OTP version just installed to verify whether the next installation is successful:

❯ vfox use -g 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> 
Enter fullscreen mode Exit fullscreen mode

If you can correctly wake up the REPL (Read-Eval-Print Loop) interactive command line, then the installation is fine. Next, start installing Elixir

3、Install Elixir via vfox-elixir plugin

Before installing the specified Elixir version, make sure that the currently installed shell can find the toolchain related to the installed Erlang/OTP version.

# Before the installation starts, switch to the Erlang version that Elixir depends on:
vfox use -g erlang@26.2.2

# Install an Erlang/OTP compatible version of Elixir
> vfox search elixir
Please select a version of elixir to install [type to search]:
->  v1.16.2-elixir-otp-26
   v1.16.2-elixir-otp-25
   v1.16.2-elixir-otp-24
   v1.16.1-elixir-otp-26
   v1.16.1-elixir-otp-25
   v1.16.1-elixir-otp-24
   v1.16.0-rc.1-elixir-otp-26
   v1.16.0-rc.1-elixir-otp-25
   v1.16.0-rc.1-elixir-otp-24
   v1.16.0-rc.0-elixir-otp-26
   v1.16.0-rc.0-elixir-otp-25
   v1.16.0-rc.0-elixir-otp-24
   v1.16.0-elixir-otp-26
   v1.16.0-elixir-otp-25
   v1.16.0-elixir-otp-24
   v1.15.7-elixir-otp-26
   v1.15.7-elixir-otp-25
   v1.15.7-elixir-otp-24
   v1.15.6-elixir-otp-26
   v1.15.6-elixir-otp-25
Press ↑/↓ to select and press ←/→ to page, and press Enter to confirm

# such as:
vfox install elixir@v1.16.1-elixir-otp-26
.....
.....
Install elixir@1.16.1-elixir-otp-26 success!
Please use vfox use elixir@1.16.1-elixir-otp-26 to use it.
Enter fullscreen mode Exit fullscreen mode

When you see the relevant information such as Install elixir@1.16.1-elixir-otp-26 success! Please use vfox use elixir@1.16.1-elixir-otp-26 to use it., it means that the installation has been completed. Next, verify the availability:

❯ vfox use -g elixir@1.16.1-elixir-otp-26
Now using elixir@1.15.2.
> iex.bat
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]                                                                                                                                              Interactive Elixir (1.16.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
Enter fullscreen mode Exit fullscreen mode

If Elixir's REPL (Read-Eval-Print Loop) interactive command line can be opened normally, then the installation is successful and available.

In the end

vfox's two plug-ins for installing and managing Erlang/OTP and Elixir versions also support managing multiple versions under Uinx-like (Linux & Darwin MacOS) system. You can check this document for more information:https://github.com/version-fox/vfox-elixir. Full platform operating system support ~

Happy & funny!

Top comments (2)

Collapse
 
simonmcconnell profile image
Simon McConnell

I think you should remove "-elixir" from the elixir version.

Why aren't the Erlang versions sorted?

Collapse
 
yeshan333 profile image
yeshan333

I tried the version of Erlang was sorted.

Image description