简体   繁体   中英

Edeliver/Distillery fails with “bash: line 10: mix: command not found” error?

I get this error when I run mix edeliver build release production --verbose

A remote command failed on:
  deploy@80.111.111.80

But when I log into the server, Elixir (and thus Mix) seem to be installed fine.

ssh deploy@80.111.111.80
deploy@80.111.111.80:~$ mix -v
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Mix 1.5.0

It seems to be working fine. What is Edeliver having trouble with finding my Elixir install? I used asdf version manager to install Elixir and Erlang.

I added . $HOME/.asdf/asdf.sh . $HOME/.asdf/asdf.sh at the bottom of my ~/.profile .

Maybe asdf?

I have installed Elixir and Erlang using asdf and I had the same problem you do.

Apparently, asdf only executes in interactive mode, which means that if I connect via ssh to the server I can run it and use mix as usual, but if from a different machine I try to execute a command ( by not physically logging in and interacting with the terminal ) then it fails with the same error you have.

Possible solutions

There are two possible solutions to this issue:

  1. Install erlang and elixir natively as described in the original documentation .
  2. Change the .bashrc file

Instal Erlang and Elixir natively

The first solution, as proposed by @Gus, would technically work.However, you would be stuck with a specific erlang/elixir version in your machine, swapping between versions would be impossible and updates as well as fixes would not be available as quickly.

For me, someone who has several Elixir projects with different versions, this solution is a big "no-no".

Change the .bashrc file

The second solution is to manually edit your ~/.bashrc file. By default, unless you are logging in interactively (by hand) the system won't load mix , user environment vars and other things. To change this behaviour you can comment the following code ( or delete it )

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

This solution is dirty, but if you use it you get full access to everything, just as if you were accessing manually.

Problems

The issues with these solutions is that they don't use Edeliver, they simply use Distillery.

Another problem is that the second solution is quite hacky, so I am not sure it is a good practice (not to mention potential security implications).

Hope it helps!

只需按照这些说明在服务器上重新安装exilir和erlang即可

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM