asdf-elixir: Running `iex -S mix phx.server` fails
Running iex -S mix phx.server
fails:
$ iex -S mix phx.server
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [hipe]
** (SyntaxError) /home/jarmo/.asdf/shims/mix:3:18: syntax error before: '.'
(elixir 1.11.2) lib/code.ex:931: Code.require_file/2
Running mix phx.server
seems to work without any issues.
Erlang and Elixir are system
installations on Ubuntu 16.04.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 33 (9 by maintainers)
@Stratus3D
I’m pretty sure that I followed asdf instructions in the doc and did the same when installing Elixir/Erlang long before installing asdf. I don’t think that I have done anything to steer off the path of “official” way of installing/loading either of these.
I have created two Dockerfiles to reproduce this problem.
First is a Docker file, which uses only system installation to show that it works as expected:
It works as expected:
Now, let’s add Dockerfile for asdf:
This also works as expected:
However, when you uncomment last
CMD
line inDockerfile.asdf
so thatsystem
versions of Elixir and Erlang would be used then problems happen:Hope this helps.
Somehow, between outcommenting the the line
. $HOME/.asdf/asdf.sh
, checking different shell scripts and undoing the uncomment, something changed for the better and now everything works without problems. So for me it was some path problem.For me using
asdf exec
as a command prefix still results in the same error as without.I’m having a similar problem on Mac OS, where system versions of erlang, elixir and hex were installed before I added asdf.
When I’m inside a Phoenix project and run
iex -S mix phx.new
I get the same error as @jarmo. However, using the slightly more convolutedasdf exec iex -S mix phx.server
works fine. Smells like some kind of path issue, but right now I’m not smart enough to see how it can be solved to work as usual.Edit:
It seems to be related to the line
. $HOME/.asdf/asdf.sh
in my shell-config (~/.zshrc) that I added during asdf installation, or rather, the referenced fileasdf.sh
. Outcommenting that line gives me access to the system version of elixir (1.13.1) and I can still useasdf exec iex -S mix phx.server
to get the asdf version.About other version managers - I have only chruby installed for managing Rubies, but not anything else for Elixir/Erlang.
Yes, Erlang 23.0 and Elixir 1.11.2 were installed before and I used
iex -S mix phx.server
pretty often for development. Until yesterday asdf was not installed on my machine, but I needed newest versions of Erlang and Elixir to try out the newest version of Phonenix Framework, which made me to look into asdf, since I didn’t want to cause any issues to my older project by upgrading Erlang and Elixir system-wide.When I comment out asdf in my
.zshrc
then I can useiex -S mix phx.server
for my older project without any issues as was the case before installing asdf.Also, as mentioned when I install the same versions of Erlang and Elixir with asdf and set them as local versions for the same older project then everything works too so it’s not that big of a problem that system installations will not work - I can even uninstall them since everything works with asdf too.