-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Windows
All things related to Elixir on Windows.
Note: There's an alternative approach here that will allow you to skip using cygwin/msys, etc. in favor of executing Linux binaries directly - no VM required at all - on your Windows 10 machine. Skip to the section on WSL for more.
The recommended way to build Elixir on Windows is with tools provided by MinGW and MSYS. Although MinGW is used for building Elixir, it is not necessary for running Elixir. In addition to MinGW, you'll need Git and Erlang on your system.
First, if you don't already have the MinGW Installation Manager on your system, download mingw-get-setup.exe here and run it. This will provide a package manager interface from which you can install the necessary MinGW/MSYS components. In the interface, mark the following packages for installation:
- msys-bash (bin)
- msys-grep (bin)
- msys-make (bin)
Then, in the Installation menu, select Apply Changes.
Finally, you'll need to add the directory containing these packages to your system's Path environment variable. By default the path is C:\MinGW\msys\1.0\bin
. To do this:
- Press
Win
+R
to open the Run dialog - Type "SystemPropertiesAdvanced.exe" and press
Enter
. - Click "Environment Variables..."
- Under "System variables", select "Path" and then click "Edit..."
- Append the directory to the variable value, using a semicolon to separate the directory form the other entries.
- Click "OK" in each of the open windows.
If you don't already have Git installed, you can download it here and install it. A directory containing git.exe
needs to be in your Path environment variable (see above for how to add it). By default, the installation puts git.exe
in C:\Program Files (x86)\Git\cmd
.
If you don't already have Erlang installed, you can download it here and install it. A directory containing erl.exe
needs to be in your Path environment variable (see above for how to add it). By default, the installation puts erl.exe
in C:\Program Files\erlX.Y\bin
or C:\Program Files (x86)\erlX.Y\bin
.
Once you have the necessary tools, open up a Command Prompt in your favorite directory and follow these steps to compile Elixir:
- Clone the Elixir repo to your system using
git clone https://github.com/elixir-lang/elixir.git
- Change into the repo directory using
cd elixir
- Run
make
.
It's that simple!
Here are some snags you might run into while working with Elixir on Windows.
- Symlinks creation requires Administrator privileges by default;
File.ln_s/2
will return{:error, :eperm}
if the associatederl.exe
orwerl.exe
process is not running as an Administrator. You can allow creation of symlinks by normal users by following the steps on https://superuser.com/a/125981 - Paths with backslashes aren't supported because the backslash is used for escape characters. For example,
C:\Users\Chris
doesn't work, butC:/Users/Chris
orC:\\Users\\Chris
do. - There is problem with variable
MAKE
inMakefile
- it causes this error during compilation:The easiest workaround is to add linePS C:\projects\elixir> make clean test #cd lib/elixir && "/c/projects/elixir/rebar" clean #==> elixir (clean) #rm -rf ebin #rm -rf lib/*/ebin #/bin/sh: /c/projects/elixir/C:/MinGW/msys/1.0/bin/make.exe: No such file or directory #make.exe": *** [clean] Error 127
MAKE = make
to the beginning ofMakefile
...stands for Windows Subsystem for Linux and is an implementation of Linux kernel syscalls directly in the Windows 10 kernel itself. This means fully compiled, native 64-bit Linux binaries will run directly on Windows without any VM!
As of this writing it's still considered "beta" by Microsoft, but don't let that scare you off: the vast majority of
competent users have reported great success in using this feature. Early releases
had not yet solved problems like binding to, say, localhost:8080
from a process launched under WSL/bash and being
available from the browser running on the regular Windows side of things, but that seems to have been worked out
for a while now. Some users have even been able to run X11 applications natively on Windows 10! (And some of them
have been doing it since WSL's very first early releases!)
Quick walk-through:
- Make sure you're logged in as a local user with full admin privileges.
- Hit start, find the "Settings" app (not Control Panel, literally it's a Universal Windows Platform (UWP) app called "Settings"; yeah, I agree it's somewhat ambiguous but meh, carry on...)
- Click the big "Update and Security" grid square
- Now on the left side toward the bottom of this text list you should see an entry entitled "For Developers". Hit it.
- Click the "Developer Mode" radio button. Close the window (there's no "Apply/OK" button in this app)
- Back to the desktop -> click Start and find "Control Panel" then open it.
- Control Panel -> Add/Remove Programs -> Left side panel, look for "Windows Features" and click it
- Scroll through the list and find "Windows Subsystem for Linux" and check it, hit OK
- Let it install and reboot. You know how Windows just looooves to be rebooted :)
- After it's back up, log in to that same admin-enabled account again
- Hit the
WIN+X
key combo (yes, X, that's not a typo) and find the option to run Windows PowerShell as an Administrator - Click the "yeah yeah nobody cares" button (User Access Control prompt) and then when your Powershell prompt is up, run this:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Let it finish its thing, then run this (also as an admin user in PowerShell - same shell session should be fine)
bash
Now you'll be prompted to agree to some crazy legal terms so just accept it blindly like everybody does and it'll perform the full installation of WSL. When that's done you'll be asked to create a user and a password. These are totally SEPARATE from your normal Windows user account/password. As long as your dev box is secure (say, a full desktop in your home which just happens to be an underground bunker or something), you can just make this "dev/dev" if you want.
But don't forget that password. You'll need it to install packages because you'll still have to sudo apt ...
to
administer the Linux side of things.
Yeah so you done that? Great. Now if it says reboot, then reboot. However don't be surprised if you don't have to.
When that's done, just launch a regular terminal process (WIN+R
, then type cmd
and hit enter, or WIN+X
and
click the non-admin PowerShell option), then type bash
and hit enter. In fact, you might...haha, "bash" that enter key,
if you know what I mean. 🙄 😆
Congratulations, you're now running Linux NATIVELY on the Windows 10 kernel!
For kicks, try installing neofetch!
$ sudo add-apt-repository ppa:dawidd0811/neofetch && sudo apt update && sudo apt install neofetch -y $ neofetch
You should see output similar to what the author of neofetch shows on the project's GitHub readme.
Links + Info
- WSL Release Notes
- HyperTerm is a cross-platform desktop terminal emulator (electron-shell, Win/Mac/Linux)
- Microsoft/BashOnWindows is the official bug-tracking repo for the project
- WSL Project Blog has some headlines but not as many as...
- ...the Windows Command Line Blog, which also has pertinent info on WSL
- Official Documentation for WSL can be found on MSDN.