Search code examples
centoselixir

Runing mix new app_first failed on CentOS


I also encounter the problem: Runing mix new app_first failed in Elixir.

It runs on centos. This is the message:

The erlang version is normal :

github@localhost:$ erl
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

The elixir version is normal

github@localhost:~/elixir-otp-24$ bin/elixir --version
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Elixir 1.14.0 (compiled with Erlang/OTP 24)

But the mix is abnormal

github@localhost:~/elixir-otp-24$ bin/mix
{"init terminating in do_boot",{badarg,[{erlang,apply,[{'Elixir.Kernel.CLI.Config',[],<<".">>,[],true,[],[],false},update_commands,[#Fun<Elixir.Kernel.CLI.18.41400255>]],[{error_info,#{module=>erl_erts_errors}}]},{'Elixir.Kernel.CLI',process_argv,2,[{file,"lib/kernel/cli.ex"},{line,191}]},{'Elixir.Kernel.CLI',main,1,[{file,"lib/kernel/cli.ex"},{line,14}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({badarg,[{erlang,apply,[{_},update_commands,[_]],[{_}]},{Elixir.Kernel.CLI,process_argv,2,[{_},{_}]},{Elixir.Kernel.CLI,main,1,[{_},{_}]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done

I have tried many ways, such as building from source. But it always failed.


Solution

  • I find the anwer: it should be setting environment variables.

    PATH=/data/github/elixir-otp-24/bin:$PATH
    
    • Put it in .bashrc
    • Source .bashrc
    • It works
    github@localhost:~$ mix
    ** (Mix) "mix" with no arguments must be executed in a directory with a mix.exs file
    
    Usage: mix [task]