How to have latest version of Elixir in Windows

Background

I am on a Windows machine and I am looking to install the latest version of elixir in it. This is being harder than expected.

Research

Initially I searched for something similar to asdf for Windows, but there is nothing similar for this platform. Scoop is the tool that comes closest, but it requires me to do custom scripts and to learn another tool, both things I am not a fan of right now:

Then I turned to chocolatey:

Which looks perfect, but it is severely outdated, being only in version 11.X
No signal of any updates to come, so this one is out as well.

My last hope, is perhaps Docker …
https://hub.docker.com/_/elixir

It looks like there is a version of 12.X, which hopefully uses OTP 24 (my goal):

Questions

However, I am not convinced yet. My only experiences with Docker containers were brutally painful. I understand things have changed in the meantime and that Docker seem to be a solution most developers fight for.

However, I am not sure if investing in this tool (remember, I discarded scoop because I didn’t want to invest in it) is going to pay off:

  • Will I be able to create releases for Windows using a container?
  • Will I be able to create releases for Ubuntu as well? (I am fairly sure I won’t be able to because my host is Windows, but just confirming)
  • Do you guys recommend any guides for Windows?

Alternatives

I feel like I am reaching for the bottom of the barrel here. I am honestly running out of options. Any ideas would be welcome.

Just use WSL 2, it’ll make your life so much easier.

I don’t feel qualified answering all of your questions, but for this one: Using a tool like Docker Desktop you can run both windows images and unix images on a Windows host. As far as I know you cannot manage them at the same time but I frequently switch between “using windows containers” and “using Linux containers” depending on my current needs

1 Like

The question you refer to was about installing and managing multiple elixir versions. Here you’re asking about installing the latest version. I’m a WSL2 user myself, so am not familiar with the windows native tooling, but doesn’t the downloadable win32 setup wizard install the latest version as you require?

Elixir’s official site does claim to have a win32 installer. If for some reason it’s problematic, I don’t think ‘use an entirely different platform’ is the best response.

No, it wont. I develop on windows because I need to compile and release for windows. I can have Ubuntu all day long in a dual boot if I want to. This is not what the discussion is about.

Will I be able to create a release for Ubuntu (that works on Ubuntu) if I use this method?
Can you link me to some resources if you don’t mind?

As I explain, the question I refer to was my first attempt at solving this issue. This is another question, therefore I created another post. It doesn’t mean however that the knowledge gained from the previous post is not useful. It means I need to refine it more.

Regarding the setup wizzard you mention,it does install a version of elixir 1.12.3, but with OTP 22 (it installs to C:\Program Files\erl10.7):

https://www.erlang.org/docs/versions/

I need a version compiled with OTP 24.0.5 (at least) so I can’t use it either.

The latest precompiled erlang version for windows from Erlang Programming Language seems to be 24.0, so if you want a later point release I suspect you’ll have to either wait or compile it yourself (which doesn’t sound very appealing I’d agree).

But even if I install Erlang with OTP 24.0, I still think I wouldn’t be able to install Elixir from the setup wizzard, as it doesn’t give me the choice of selecting which erlang version I want to use. Right?

As in, for example, installing Elixir 1.12.3 with OTP 24.0.
As far as I can understand, the installer simply asks me to install Erlang 10.7 (with OTP 22.X).

While the installer may not be that flexible you can always compile from source: Windows · elixir-lang/elixir Wiki · GitHub

The installer is just a convenience to hide the complexities involved for windows users and the (pre-)build versions only support the lowest supported otp version.

1 Like

I myself use a custom scoop bucket, but what it does can simple be done without it.

  1. Choose your disired precompiled elixir version from https://repo.hex.pm/builds/elixir/builds.txt
  2. Download from e.g. https://repo.hex.pm/builds/elixir/v1.12.3-otp-24.zip
  3. Extract and set the bin folder to your windows path

Edit:
Of course you have to take care of the runtime Erlang version installation separately.
No, creating a release on native Windows for Ubuntu won’t work.
But creating a release for Windows within a Docker container won’t work ether in my view.

2 Likes

That’s interesting. I wouldn’t have thought that those prebuilds of hex just work on windows.

Been there, done that. There is a fair amount of documented friction running Elixir on Windows - but you can search the forum and make your own opinions about it. IMHO the current experience on *NIX is far better and if you don’t have to target Windows, just use WSL instead.

BTW: The question didn’t imply he wanted to compile/ release just for Windows. So I think since WSL is part of Windows tooling it’s in fact a valid answer.

Are you doing Phoenix? What are your constraints on compiling a release for Windows if I may ask?

Another option could be reevaluating Docker if you just want to run your code without caring about the platform’s limitations. But this depends on what you need, if it’s an application that you’ll have to deploy constantly or if its just a one-off thing.

PS.: I used to use Chocolatey, the maintainer of the Elixir package was looking into adding a CI to generate releases dynamically but I don’t know what’s the status on that. If this is important to you, check with him if you can help.

For elixir-desktop I also needed recent windows binaries, so I did contribute a GitHub CI job for windows some time ago. So you can get the most recent Erlang binaries directly from the official OTP GitHub Repo. Just go to the commit of the release you want, click on the green CI checkmark and choose “artifacts” from there. E.g. this is the link for the 24.0.5 build:

For Elixir, I’m not sure whether it changed but if I remember correctly it will just use whatever Erlang version is in your System PATH variable. So if you use windows native just set the path environment variable to the folder where your erl.exe is.

If you’re using msys2 (which I recommend) then you can make the change in your .bashrc

Cheers!

1 Like

I absolutely agree. However, I do have to target Windows for this project, which is why this discussion was created.

Perhaps I could have made my point more clear. I will take this into consideration next time, thanks for pointing out.

I am doing Phoenix, yes. My constraint is I would have to do it for every new release of erlang/elixir and I am not sure this would be manageable on my side. Compilations rarely go without issues.

There are a lot of good suggestions here, I will try to check some of them.