by e3bc54b2 · 4y ago · 0 comments
A friend and I have been trying it for a project and for a NixOS dweller like me it was less than 2 minutes of work. But for her it has been never ending troubles.
Otherwise, Elixir and Phoenix are fantastic! No explicit JavaScript is necessary and that alone sells it for me, but the concurrency story is so easy to grok that I'm amazed nobody else managed to recreate it in so many years..
For running directly on Windows you can simply run the Elixir installer, which will install Erlang and Elixir. After that, I highly recommend using the ElixirLS extension for Visual Studio Code. Note that on Windows, you need to use `iex.bat` and `mix.bat` instead of just `iex` and `mix` when running the commands. For example, `iex.bat -S mix.bat`. (I have it setup where I can leave off `.bat` for `mix`, but I can't remember what I did off the top of my head, if anything, to get that. `iex` conflicts with a PowerShell thing, so `iex.bat` is required.)
The other option is to install WSL2, install Erlang and Elixir there (I recommend using the asdf package manager (https://asdf-vm.com/). Once installed, use the Remote - SSH extension in Visual Studio Code on the Windows side to remote into the WSL2 instance. You could also download an official Elixir Docker container and again use Visual Studio Code (https://code.visualstudio.com/docs/devcontainers/containers).
I’ve made a doc for setting up Windows machines that I’ve been planning to share online but haven’t gotten around to yet. I’ll try to tonight and update this thread with a link.
Tldr; use WSL2 and Ubuntu stable. Use ASDF. Put your app on the Linux part of the filesystem and if your Postgres installation is also on the Linux side, then have bash start it for you.
kvm/Hypervisor support on windows is patchy, but there are a lot of lower performance virtual machines that can work.
I couldn't get Elixir 1.14 to work in September actually and reverted to 1.13.4, maybe I should try again.
But, after installing Elixir and pointing it to the otp 25.0.4 folder.
> elixir -v
> Cannot find file at 'c:\program files\erl-24.0\erts-12.0\bin\erl.exe' c:\program files\erl-24.0\erts-12.0\bin\erl.exe). This usually indicates a missing or moved file.
I install erl-24.0
> elixir -v
> Could not load module C:\Program Files\erl-24.2.2\erts-12.2.1\bin\erlexec.dll.
I install erl-24.2.2
> elixir -v
> {"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_em,1,[{file,"init.erl"},{line,1191}]},{init,do_boot,3,[{file,"init.erl"},{line,889}]}]}} init terminating in do_boot ({undef,[{elixir,start_cli,[],[]},{init,start_em,1,[{_},{_}]},{init,do_boot,3,[{_},{_}]}]})
All the while erl-25.0.4 doesn't seem used (while being in the PATH env), I guess that's the problem but how do you enforce the OTP version?
----
edit:
So I kinda made it work. First I noticed that I had erl-24.0 installed by Chocolatey (which I don't remember using ahah) so I uninstalled that.
To make it clear, I'm on Windows 7 so the problems may come from that, but maybe it will help somebody else.
But then the elixir-websetup.exe (2.2) would not actually complete any longer (while doing so when erl-24 was installed by Chocolatey?), it could not find the actual elixir downloaded installer in C:\<Me>\etc (not the valid user path in Windows 7 but maybe in 10+ ?)
I then used elixir-websetup.exe 2.1 and got almost the same error but this time it complained about "elixir-v1.14.1 (Erlang/OTP 25)-setup.exe" while it actually downloaded "elixir-v1.14.1-setup.exe", which I was able to launch myself and finish the setup.
And voilà, Elixir 1.14.1 ;)
This may be a bit too much, but maybe try removing all Erlang and Elixir versions and just picking the latest for both?
If you are on WSL, then `asdf` or similar can do the trick.