Elixir: `iex -S mix` results in `-S : Could not find executable mix` on Windows with OTP21

Created on 21 Jun 2018  路  12Comments  路  Source: elixir-lang/elixir

iex -S mix results in -S : Could not find executable mix in a seemingly good Win10 environment with Elixir 1.6.6 & OTP21.

Environment

  • Erlang/OTP: 21
  • Elixir: 1.6.6
  • OS: Windows 10 (Version 1803 OS Build 17134.112)

Current behavior

I did a clean install of Erlang (otp_win64_21.0.exe) and Elixir (elixir-v1.6.6-setup.exe) on my Windows 10 box (Version 1803 OS Build 17134.112).

C:\Users\chgeuer> mix new bar && cd bar

    * creating README.md
    * creating .formatter.exs
    * creating .gitignore
    * creating mix.exs
    * creating config
    * creating config/config.exs
    * creating lib
    * creating lib/bar.ex
    * creating test
    * creating test/test_helper.exs
    * creating test/bar_test.exs

    Your Mix project was created successfully.
    You can use "mix" to compile it, test it, and more:

        cd bar
        mix test

    Run "mix help" for more commands.

C:\Users\chgeuer\bar> iex -S mix

    -S : Could not find executable mix

Looking in an interactive session:

C:\Users\chgeuer>iex
    Erlang/OTP 21 [erts-10.0] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
    Interactive Elixir (1.6.6) - press Ctrl+C to exit (type h() ENTER for help)

    iex(1)> :erlang.system_info(:otp_release)
    '21'

    iex(2)> System.version
    "1.6.6"

    iex(3)> System.get_env("PATH")
    nil

    iex(4)> System.get_env("Path") |> String.split(";") |> Enum.filter(&(String.contains?(&1, "Eli") or String.contains?(&1,"erl")))
    [
        "C:\\Program Files\\erl10.0\\erts-10.0\\bin",
        "C:\\Program Files\\erl10.0\\bin", 
        "C:\\Program Files (x86)\\Elixir\\bin"
    ]

When I run "C:\Program Files (x86)\Elixir\bin\iex.bat" "C:\Program Files (x86)\Elixir\bin\mix", it works...

Erlang bug Open for guidance Windows

Most helpful comment

I have also updated the official Windows Installer to use 21.0.1.

All 12 comments

Thanks @chgeuer! What happens if you do System.find_executable("mix") in iex? If that doesn't work, that would be the root cause. :)

Do you have OTP 20 (or earlier) installed as well? If so, what is the result of this on both versions:

erl -noshell -eval 'erlang:display(os:getenv("PATH")), halt()'

It seems to be a case sensitivity issue with the new Erlang version.

I re-installed Erlang 9.3/OTP20:

  • Erlang 9.3/OTP20 gives the "Path" environment variable for both os:getenv("Path"). and os:getenv("PATH")..

  • Erlang 10.0/OTP21 gives the "Path" environment variable only for os:getenv("Path"). . But os:getenv("PATH"). gives me false.

It seems that Erlang 10.0 is more strict on environment variable name casing, which causes that problem.

On the Win10 box, the Path variable seems not easily to be renameable to PATH.

This is a regression in OTP:

https://bugs.erlang.org/browse/ERL-644

Maybe we should work around this issue in Elixir by checking both PATH and Path?

We don't read it directly - :os.find_executable does on it's own. It seems :os.find_executable is completely broken on Windows right now - this seems like a much more severe issue than just case-insensitive :os.getenv and might cause the OTP team to reconsider a release.

Can somebody with a windows machine verify what does :os.find_executable('erl') return? If it doesn't work (and it seems to me it won't), that seems like a major issue.

Hi @michalmuskala here you go:

C:\Users\chgeuer>"C:\Program Files\erl9.3\bin\erl.exe"
Eshell V9.3  (abort with ^G)                          
1> os:find_executable('erl').                                                     
"c:/Program Files/erl9.3/erts-9.3/bin/erl.exe"        
2>                                                    


C:\Users\chgeuer>"C:\Program Files\erl10.0\bin\erl.exe"
Eshell V10.0  (abort with ^G)
1> os:find_executable('erl').
false
2>

@michalmuskala Assuming it's the environment variable lookup that is broken we could use :os.find_executable/2 passing in the PATH explicitly. http://erlang.org/doc/man/os.html#find_executable-2

Is there a workaround for this?

Is there a workaround for this?

No, if you use Windows we recommend staying on OTP 20 for now.

A fix for this issue was released as part of OTP 21.0.1

I have also updated the official Windows Installer to use 21.0.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexrp picture alexrp  路  4Comments

ericmj picture ericmj  路  3Comments

josevalim picture josevalim  路  3Comments

whitepaperclip picture whitepaperclip  路  3Comments

sashaafm picture sashaafm  路  3Comments