asdf icon indicating copy to clipboard operation
asdf copied to clipboard

asdf uses system version even if executables are not in the PATH

Open pi-dal opened this issue 5 years ago • 7 comments

I can't use

asdf global python system 3.8.2

like pyenv in asdf

pi-dal avatar Aug 05 '20 10:08 pi-dal

Can you explain what you expect to happen with this command and what happened instead? I am going to need more information in order to be able to help.

Stratus3D avatar Aug 05 '20 14:08 Stratus3D

When I use pyenv, I use the following command:

pyenv global system 3.8.2

It can use python, python3, python3.8 at the same time. But when I use asdf, I use the following command:

asdf global python system 3.8.2

It can only use python, python3. No way to use python3.8

pi-dal avatar Aug 05 '20 22:08 pi-dal

It can only use python, python3. No way to use python3.8

I think this may be a limitation of the python plugin. @danhper can you weigh in on this? I don't know enough to say anything for sure, but perhaps asdf-python keeps the python3.8 executable named python3, in which case it conflicts with the other version of python3?

Stratus3D avatar Aug 06 '20 13:08 Stratus3D

After double-checking, it rather seems to be an issue with how we handle the system version. I think that if we give the system version first, asdf will always use the system version even if no such executable exists. My system Python default is 3.8 so I tried with 3.7 but it does not behave as I would have expected.

asdf global python system 3.7.7
$ cat ~/.asdf/shims/python3.7
#!/usr/bin/env bash
# asdf-plugin: python 3.7.2
# asdf-plugin: python 3.7.7
exec /home/daniel/.asdf/bin/private/asdf-exec "python3.7" "$@"
$ asdf which python3.7
No python3.7 executable found for python system

I personally use a custom asdf-exec to run the binary and this seems to work fine:

$ python3.7 --version
Python 3.7.7

The issue is easy to reproduce with pretty much any plugin. Given bundle is not installed globally:

$ asdf global ruby system 2.6.1 
$ asdf which bundle
No bundle executable found for ruby system
$ asdf global ruby 2.6.1 system 
$ asdf which bundle
/home/daniel/.asdf/installs/ruby/2.6.1/bin/bundle

I think the issue comes from get_shim_versions which wrongly adds the system version even if the given executable is not available on the system. We need to check whether the executable is on the path or not before considering it to be a candidate. It should not be too hard to fix but I'm not sure what is the best way to do so yet. Maybe simply checking the path without the ~/.asdf/shims directory from within get_shims_versions? @Stratus3D What do you think?

danhper avatar Aug 06 '20 13:08 danhper

Is there any update for this? @danhper, are your custom asdf executable working to this date?

Update

Between my attempts to get it working, somewhat it got working.
The problem is: I really don't know how I did it. I've tried:

  • restarting the console
  • asdf reshim python
  • asdf reshim

And, FTR, set the python version by including the "system" word in the command didn't work either.

RichardsonWTR avatar Apr 01 '21 14:04 RichardsonWTR

I have a similar issue.

The terminal is using local python executable instead asdf.

Here is the scenarios:

# command
asdf list python

# output
  3.7.8
# command
asdf local python 3.7.8

# output
# command
python --version

# output
Python 2.7.16
# command
python3 --version

# output
Python 3.9.10
# command
which python

# output
/usr/bin/python
# command
which python3

# output
/usr/local/bin/python3
# command
asdf where python

# output
/Users/myuser/.asdf/installs/python/3.7.8

I already did:

  • Restart the console
  • Restart the machine
  • asdf reshim
  • asdf reshim python

benhurott-cwi-via avatar Feb 16 '22 18:02 benhurott-cwi-via

I have a similar issue.

The terminal is using local python executable instead asdf.

Here is the scenarios:

# command
asdf list python

# output
  3.7.8
# command
asdf local python 3.7.8

# output
# command
python --version

# output
Python 2.7.16
# command
python3 --version

# output
Python 3.9.10
# command
which python

# output
/usr/bin/python
# command
which python3

# output
/usr/local/bin/python3
# command
asdf where python

# output
/Users/myuser/.asdf/installs/python/3.7.8

I already did:

  • Restart the console
  • Restart the machine
  • asdf reshim
  • asdf reshim python

Hey @benhurott-cwi-via - I had a similar issue as you and I tried the follows from the asdf page:

if using macOS Catalina or newer, the default shell has changed to ZSH. Unless changing back to Bash, follow the ZSH instructions.

Add asdf.sh to your ~/.bash_profile with:

echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.bash_profile
Completions will need to be configured as per Homebrew's instructions or with the following:

echo -e "\n. $(brew --prefix asdf)/etc/bash_completion.d/asdf.bash" >> ~/.bash_profile

Restarted my shell after this and it worked for me in case of Python as well as another plugin Helm which wasn't being detected too. Hope it helps!

rohitss912 avatar Jul 11 '22 08:07 rohitss912