Giter Site home page Giter Site logo

Comments (34)

jarmo avatar jarmo commented on May 25, 2024 1

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 use iex -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.

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024 1
$ type -a iex
iex is /home/jarmo/.asdf/shims/iex
iex is /usr/bin/iex
$ type -a mix
mix is /home/jarmo/.asdf/shims/mix
mix is /usr/bin/mix

About other version managers - I have only chruby installed for managing Rubies, but not anything else for Elixir/Erlang.

from asdf-elixir.

MathiasWedeken avatar MathiasWedeken commented on May 25, 2024 1

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 convoluted asdf 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 file asdf.sh . Outcommenting that line gives me access to the system version of elixir (1.13.1) and I can still use asdf exec iex -S mix phx.server to get the asdf version.

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024 1

For me using asdf exec as a command prefix still results in the same error as without.

from asdf-elixir.

MathiasWedeken avatar MathiasWedeken commented on May 25, 2024 1

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.

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024 1

@Stratus3D

But in any case if you follow the instructions in the asdf docs you should have a working setup.

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:

# Dockerfile.system

FROM ubuntu

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update -y
RUN apt upgrade -y
RUN apt install -y wget

# System installation of Erlang and Elixir according to https://elixir-lang.org/install.html
RUN wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && apt install -y --fix-broken ./erlang-solutions_2.0_all.deb
RUN apt update -y
RUN apt install -y esl-erlang
RUN apt install -y elixir

WORKDIR /home/elixir
CMD iex -S mix help

It works as expected:

$ docker build -t elixir-test -f Dockerfile.system . && docker run --rm -it elixir-test
Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]
...
Interactive Elixir (1.13.0) - press Ctrl+C to exit (type h() ENTER for help)

Now, let's add Dockerfile for asdf:

# Dockerfile.asdf

FROM ubuntu

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update -y
RUN apt upgrade -y
RUN apt install -y wget

# System installation of Erlang and Elixir according to https://elixir-lang.org/install.html
RUN wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && apt install -y --fix-broken ./erlang-solutions_2.0_all.deb
RUN apt update -y
RUN apt install -y esl-erlang
RUN apt install -y elixir

# asdf installation of Erlang and Elixir
RUN apt install -y curl git build-essential libssl-dev automake autoconf libncurses5-dev
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.9.0
RUN echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc
RUN bash -ic "asdf plugin add erlang && \
      asdf install erlang latest && \
      asdf plugin add elixir && \
      asdf install elixir latest"

WORKDIR /home/elixir
CMD bash -ic "asdf local erlang latest && asdf local elixir latest && iex -S mix help"
#CMD bash -ic "asdf local erlang system && asdf local elixir system && iex -S mix help"

This also works as expected:

$ docker build -t elixir-test -f Dockerfile.asdf . && docker run --rm -it elixir-test
Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]
...
Interactive Elixir (1.13.3) - press Ctrl+C to exit (type h() ENTER for help)

However, when you uncomment last CMD line in Dockerfile.asdf so that system versions of Elixir and Erlang would be used then problems happen:

$ docker build -t elixir-test -f Dockerfile.asdf . && docker run --rm -it elixir-test
** (SyntaxError) /root/.asdf/shims/mix:3:12: syntax error before: '.'
    |
  3 | exec /root/.asdf/bin/asdf exec "mix" "$@"
    |            ^
    (elixir 1.13.0) lib/code.ex:1183: Code.require_file/2

Hope this helps.

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

After installing Erlang 23.0 and Elixir 1.11.2 with asdf and using them instead of system installations then everything seems to work.

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

@jarmo so this seems to be limited to when you tried to run iex -S mix phx.server with the system Erlang and Elixir versions?

Can you share the output of asdf info? Thanks!

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

Yes, as soon as I don't specify local erlang/elixir system, but specify same versions of Erlang/Elixir installed by asdf then everything seems to work as expected.

$ asdf info
OS:
Linux caesar 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)

ASDF VERSION:
v0.8.1-a1ef92a

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/jarmo/.asdf

ASDF INSTALLED PLUGINS:
elixir                       https://github.com/asdf-vm/asdf-elixir.git
erlang                       https://github.com/asdf-vm/asdf-erlang.git

Now, before Microsoft causes any confusion then the real "OS" is Ubuntu 16.04 inside WSL-1:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.7 LTS"

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

Did you have Erlang and Elixir installed on your system prior to asdf? And did they work when you ran simple things like just erl or iex?

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

Does this issue appear similar to yours? asdf-vm/asdf#1130

Also, what happens if you run asdf reshim and then try the system version with asdf?

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

asdf reshim does not seem to make any difference.

Some additional information:

$ cat .tool-versions
erlang system
elixir system

$ which erl
/home/jarmo/.asdf/shims/erl

$ which elixir
/home/jarmo/.asdf/shims/elixir

$ 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:4:18: syntax error before: '.'
    (elixir 1.11.2) lib/code.ex:931: Code.require_file/2

$ asdf reshim

$ 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:4:18: syntax error before: '.'
    (elixir 1.11.2) lib/code.ex:931: Code.require_file/2

$ cp -f .tool-versions.bck .tool-versions

$ cat .tool-versions
erlang 23.0
elixir 1.11.2

$ iex -S mix phx.server
Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [hipe]

[info] Running MyWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:4000 (https)
...

Also this:

$ asdf list
elixir
  1.11.2
  1.13.1-otp-24
erlang
  23.0
  24.2

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

This looks like the same issue - #62

Have you tried updating the plugin? asdf plugin-update elixir?

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

No, I have not tried to update anything since I did install asdf and all of its plugins last week for the first time ever.

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

Hmm... I'm out of ideas. What is the output of type -a iex and type -a mix? Do you happen to have any other version managers or anything else on your system that may interfere with asdf?

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

That all looks correct. chruby shouldn't be a problem. The only thing I can think of is maybe something is wrong with your shims and asdf reshim isn't fixing it. You could try deleting all your shims (rm /home/jarmo/.asdf/shims/*) and then running asdf reshim to re-generate them. I'm not sure this would fix anything though. I'm out of ideas.

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

Nope, didn't help. Here's my shim for mix:

$ cat ~/.asdf/shims/mix
#!/usr/bin/env bash
# asdf-plugin: elixir 1.11.2
# asdf-plugin: elixir 1.13.1-otp-24
exec /home/jarmo/.asdf/bin/asdf exec "mix" "$@"

I did read that WSL1 is not officially supported by asdf - can it be that this is the reason behind this problem although everything else seems to work as expected so far?

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

No need to even execute phx.server:

$ iex -S mix
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:4:18: syntax error before: '.'
    (elixir 1.11.2) lib/code.ex:931: Code.require_file/2

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

Yeah I'm at a loss. I have no idea what the issue is. You might check this issue tracker for others who have encountered issues on WSL. I am not familiar with WSL and it isn't officially supported by asdf as far as I know.

from asdf-elixir.

AviKav avatar AviKav commented on May 25, 2024

@Stratus3D
As far as I can tell what is happening is that asdf prepends to $PATH for asdf-elixir managed installations, but not for system installations (a.k.a., whatever it finds in $PATH)
(What it prepends is $ASDF_PREFIX/plugins/elixir/shims:$ASDF_PREFIX/installs/elixir/$VERSION/bin:$ASDF_PREFIX/installs/elixir/$VERSION/.mix/escripts:)

iex -S $script assumes/requires $script to be the name of an elixir script in $PATH (or the path to one asdf-vm/asdf#926 (comment)).

This is why with asdf {global,local} elixir system, iex -S mix looks for mix in $PATH, sees the bash script $ASDF_PREFIX/shims/mix, tries to load it, fails.

Aside: $ASDF_PREFIX/plugins/elixir/shims doesn't contain anything executable so it doesn't seem to affect anything

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

@MathiasWedeken good to know. I use asdf and elixir every day and don't encounter this issue. I suspect there could be an environmental element to this issue. Perhaps something else on the path, or some iex configuration affects this behavior. But in any case if you follow the instructions in the asdf docs you should have a working setup.

@AviKav asdf put its' shims on your $PATH, and those shims may point to asdf-managed version, or, if you've specified a system version, the version already installed on your system. Assuming iex is executing the script given with the -S this should all work. However I still don't understand why it works for me and not for others.

from asdf-elixir.

AviKav avatar AviKav commented on May 25, 2024

@Stratus3D

asdf put its' shims on your $PATH

Not all the time. While asdf's rc scripts amends $PATH so it points to the shims first, the shims, when called, amend $PATH so that they aren't pointed to first.
The problem is that they don't/can't do this for system installs

Assuming iex is executing the script given with the -S this should all work.

That would indeed be the case if iex was executing them via exec() family and not trying to read them

However I still don't understand why it works for me and not for others.

You mentioned half a year ago not having a system install to use with asdf. Is this still the case?
asdf-vm/asdf#926 (comment)

from asdf-elixir.

AviKav avatar AviKav commented on May 25, 2024

I think you may be able to make asdf think you have a system install available by adding an elixir install to '$PATH' before sourcing asdf

from asdf-elixir.

Stratus3D avatar Stratus3D commented on May 25, 2024

Thanks for the Dockerfile @jarmo ! That helps some, however I've got a coworker who has this same issue manifesting with regular versions, not system versions. Have you or anyone else here encountered that?

from asdf-elixir.

jarmo avatar jarmo commented on May 25, 2024

@Stratus3D you're welcome about Dockerfiles. I've only encountered this issue as is happening with reproducible Dockerfiles above. Not had issues like that in any other way yet.

from asdf-elixir.

aywan avatar aywan commented on May 25, 2024

Have same issue.
When install erlang localy, i added ERL_LIBS env in my .bashrc file.
After remove it - all was fixed.

from asdf-elixir.

Arie avatar Arie commented on May 25, 2024

Hitting this same issue, interestingly asdf worked correctly in one project, but not the other.

There was a slight difference in the .tool-versions file between the projects:

The non-working one:

 cat .tool-versions 
elixir 1.14.0
erlang 25.0.4

The working one:

 cat .tool-versions 
elixir 1.14
erlang 25.0.4

After changing elixir 1.14.0 to elixir 1.14 in the .tool-versions, I could launch iex -S mix again.

from asdf-elixir.

fuelen avatar fuelen commented on May 25, 2024

I've experienced the same issue with system elixir. Described it here jfpedroza/neotest-elixir#16

from asdf-elixir.

adkron avatar adkron commented on May 25, 2024

I'm having this issue today and have never had a problem. I don't know what caused this.

from asdf-elixir.

adkron avatar adkron commented on May 25, 2024

Fixed (YMMV):

Okay, I don't know what was happening as I had just installed the versions of Elixir and Erlang I was using. I tried to reshim, and that didn't fix it. I decided to do asdf uninstall elixir 1.14.4-otp-25. Then I did asdf install. The problem went away and it started working correctly. I don't like that I have no understanding of why it was broken, but if you need it to work maybe this is a good solution.

from asdf-elixir.

seletz avatar seletz commented on May 25, 2024

I have the same problem with ASDF and elixir.

Installed asdf the first time last Friday, today I needed to switch back to "system" elixir, added the system in tool-versions, did a reshim as suggested in this thread. I'm on MacOS and run the latest OSX.

Tool versions:

elixir system 1.15.0-otp-25
erlang system 25.3.2.2

Reverting the path -- essentially cutting off ASDF -- "fixes" the problem. Was there ever a correct fix found?

I seem to need my system erlang/elixir to get elixir-ls running again -- this is of course unrelated to this bug.

from asdf-elixir.

seletz avatar seletz commented on May 25, 2024

Here's my asdf info output. This is in a shell where ASDF is still in the path:

❯ asdf info
OS:
Darwin NewEden 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64

SHELL:
zsh 5.9 (x86_64-apple-darwin22.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
v0.12.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/seletz/.asdf
ASDF_DIR=/usr/local/opt/asdf/libexec
ASDF_CONFIG_FILE=/Users/seletz/.asdfrc

ASDF INSTALLED PLUGINS:
elixir                       https://github.com/asdf-vm/asdf-elixir.git master a4c42e1
erlang                       https://github.com/asdf-vm/asdf-erlang.git master 267f6bb

Here's what the shell's path resolver thinks. I'm using ZSH.

❯ type -a iex
iex is /Users/seletz/.asdf/shims/iex
iex is /usr/local/bin/iex
iex is /usr/local/bin/iex

❯ type -a elixir
elixir is /Users/seletz/.asdf/shims/elixir
elixir is /usr/local/bin/elixir
elixir is /usr/local/bin/elixir

❯ type -a erl
erl is /Users/seletz/.asdf/shims/erl
erl is /usr/local/bin/erl
erl is /usr/local/bin/erl

from asdf-elixir.

tomwang57 avatar tomwang57 commented on May 25, 2024

Same issue with newest asdf & elixir & erlang when elixie is installed before asdf and use system version.

from asdf-elixir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.