Elixir's IEx and Mix tooling, on Windows, comes with some batch scripts (.bat
) and PowerShell scripts (.ps1
) that handle these tooling applications. For example, you can run
PS > (Get-Command mix.ps1).Path
C:\Program Files (x86)\Elixir\bin\mix.ps1
to see where these scripts are located, if they are in your path already. The Elixir Winows installer does put these in your path if you select it (I think there's a selection at least, from memory).
So out of the gate, you need to run iex.bat
and mix.bat
to run these commands for Elixir, which can be problematic. See the steps below to get rid of this requirement.
The following assumes the editor is Visual Studio Code and that code
is available in the user's path.
By default, PowerShell contains an alias iex
for Invoke-Expression
. To see this:
PS > $alias:iex
Invoke-Expression
Thus, to make iex
for Elixir work, even with it in the path, this alias needs to be removed.
- Enable script execution:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
- Warning: Please read the PowerShell documentation to understand this command! I'm not responsible for unwanted scripts running on your computer.
- Open the PowerShell profile by running
code $PROFILE
. The profile may not exist. If not, see the PowerShell documentation on profiles. - Add
to your profile file. This tests if the
if (Test-Path alias:iex) { Remove-Item alias:iex -Force }
$alias:iex
exists or not, and if so, forces its removal. Note, there is a commandlet calledRemove-Alias
, but this requires PowerShell 6. - You can try running
& $profile
after saving the profile file, but this didn't work for me. Open a new PowerShell, and you should be able to runiex
now and get Elixir's IEx.
Being able to run just mix
instead of having to use mix.bat
is enabled by step (1) in the above IEx section, since this enabled PowerShell scripts to run.