asdf-vm / asdf

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
https://asdf-vm.com/
MIT License
21.6k stars 769 forks source link

"No version is set" when version is set and returned by `asdf current` [ruby] #557

Closed barberj closed 3 years ago

barberj commented 5 years ago

Following advice from https://github.com/asdf-vm/asdf/issues/488, creating new issue.

Steps to reproduce

Install new ruby. Attempt to install dependencies using bundler. Tried new session after install.

Expected behavior

Dependencies are installed.

Actual behavior

➜  git:(master) bundle install
asdf: No version set for command bundle
you might want to add one of the following in your .tool-versions file:

ruby 2.6.3
ruby 2.6.1

➜ git:(master) asdf current
elixir         No version set for elixir; please run `asdf <global | local> elixir <version>`
erlang         No version set for erlang; please run `asdf <global | local> erlang <version>`
ruby           2.5.1    (set by /Users/justinbarber/src/melody/.tool-versions)

➜  git:(master) cat .tool-versions
ruby 2.5.1

Environment

OS:

macOS Sierra 10.12.6

asdf version:

➜  git:(master) asdf --version
v0.7.3
afeld commented 5 years ago

Try running hash -r, then trying again. https://github.com/asdf-vm/asdf-ruby/issues/48#issuecomment-351787183

Maintainers: I think it's worth considering clearing the bash cache (hash -r or hash -d [executable] for each executable) somewhere... not sure of the best place for that. I wasn't even aware that bash did caching, and I bet a lot of other people aren't either. Thoughts?

barberj commented 5 years ago

I'm using zsh. hash -r didn't help seem to have any effect.

yordis commented 5 years ago

Same started happening with NodeJS.

➜ node -v
asdf: No version set for command node
you might want to add one of the following in your .tool-versions file:

nodejs 10.16.1

Worth saying that I had to put .tool-versions in that particular folder closer to where I am trying to use Node by using asdf local nodejs 10.16.1 but I am not sure why.

JamesLavin commented 5 years ago

I'm having the same issue, and I noticed that it seems to happen because asdf doesn't seem to know about a version of Ruby (2.6.3) I installed via asdf today. It recommends I use one of my three previous versions of Ruby:

james@James-Precision-5520:~/Git/elixirschool$ asdf current
elixir         1.9.0-otp-22 (set by /home/james/.tool-versions)
erlang         22.0.7   (set by /home/james/.tool-versions)
ruby           2.6.3    (set by /home/james/.tool-versions)
james@James-Precision-5520:~/Git/elixirschool$ jekyll
asdf: No version set for command jekyll
you might want to add one of the following in your .tool-versions file:

ruby 2.3.7
ruby 2.4.3
ruby 2.5.1
james@James-Precision-5520:~/Git/elixirschool$ ls ~/.asdf/installs/ruby
2.3.7  2.4.3  2.5.1  2.6.3
james@James-Precision-5520:~/Git/elixirschool$ asdf list ruby
  2.3.7
  2.4.3
  2.5.1
  2.6.3

When I changed my .tool-versions to point at one of the other three (older) Ruby installs, it started working.

Hoping this information may help with debugging.

bowmanmike commented 5 years ago

Having a similar issue. I have a Node, Elixir, and Ruby versions all set in my ~/.tool-versions file. When I cd into an Elixir project, asdf current picks up the Elixir and Ruby versions from the global file, but not Node. I can resolve the issue by adding a $PROJECT/.tool-versions file with the correct Node version, but I don't want to pollute a shared repo with a file that only I'm using.

ttilberg commented 4 years ago

Here's some info about my setup where I have the same issue. I just upgraded asdf as I saw in another issue that it might have been due to an old version, but I still have the issue.

MacOS 10.14.6 Mojave asdf installed with Brew

ttilberg:~$ which asdf
/usr/local/opt/asdf/bin/asdf

ttilberg:~$ asdf --version
v0.7.4

ttilberg:~$ cat .tool-versions
ruby 2.6.3
nodejs 10.16.0
python 3.7.4

ttilberg:~$ which python
/Users/ttilberg/.asdf/shims/python

ttilberg:~$ which pip
/Users/ttilberg/.asdf/shims/pip

ttilberg:~$ python --version
Python 3.7.4

ttilberg:~$ pip install ipython
Requirement already satisfied: ipython in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (7.8.0)
Requirement already satisfied: pygments in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (2.4.2)
Requirement already satisfied: appnope; sys_platform == "darwin" in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (0.1.0)
Requirement already satisfied: traitlets>=4.2 in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (4.3.2)
Requirement already satisfied: pickleshare in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (0.7.5)
Requirement already satisfied: jedi>=0.10 in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (0.15.1)
Requirement already satisfied: prompt-toolkit<2.1.0,>=2.0.0 in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (2.0.9)
Requirement already satisfied: setuptools>=18.5 in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (40.8.0)
Requirement already satisfied: decorator in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (4.4.0)
Requirement already satisfied: pexpect; sys_platform != "win32" in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (4.7.0)
Requirement already satisfied: backcall in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from ipython) (0.1.0)
Requirement already satisfied: ipython-genutils in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from traitlets>=4.2->ipython) (0.2.0)
Requirement already satisfied: six in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from traitlets>=4.2->ipython) (1.12.0)
Requirement already satisfied: parso>=0.5.0 in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from jedi>=0.10->ipython) (0.5.1)
Requirement already satisfied: wcwidth in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from prompt-toolkit<2.1.0,>=2.0.0->ipython) (0.1.7)
Requirement already satisfied: ptyprocess>=0.5 in ./.asdf/installs/python/3.7.4/lib/python3.7/site-packages (from pexpect; sys_platform != "win32"->ipython) (0.6.0)

ttilberg:~$ ipython
asdf: No version set for command ipython
you might want to add one of the following in your .tool-versions file:

python 3.6.8

ttilberg:~$ which ipython
/Users/ttilberg/.asdf/shims/ipython

ttilberg:~$ cat $(which ipython)
#!/usr/bin/env bash
# asdf-plugin: python 3.6.8
exec /usr/local/opt/asdf/bin/asdf exec "ipython" "$@"

The shim explicitly mentions py 3.6.8 in a comment -- I'm not sure if that's a magic comment, I'm guessing so. Being that my python seems to be correctly pointed to asdf+3.7 for all the above commands, I feel like something in this last file is amiss.

EDIT: The issue above was resolved by running asdf reshim.

betogrun commented 4 years ago

I'm facing the same issue after installing another ruby version with asdf.

$ asdf install ruby 2.4.3
$ asdf local ruby 2.4.3

$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]

$ cat .tool-versions 
ruby 2.4.3

$ bundle install
asdf: No version set for command bundle
you might want to add one of the following in your .tool-versions file:

ruby 2.6.1
ruby 2.6.3

Running asdf reshim ruby and restarted the terminal didn't fix the issue. asdf version is 0.7.4

fahmifan commented 4 years ago

I also get this issue for nodejs in mac, i solve it by adding .tool-versions

cat ~/.tool-versions
nodejs 10.15.3
betogrun commented 4 years ago

I'm facing the same issue after installing another ruby version with asdf.

$ asdf install ruby 2.4.3
$ asdf local ruby 2.4.3

$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]

$ cat .tool-versions 
ruby 2.4.3

$ bundle install
asdf: No version set for command bundle
you might want to add one of the following in your .tool-versions file:

ruby 2.6.1
ruby 2.6.3

Running asdf reshim ruby and restarted the terminal didn't fix the issue. asdf version is 0.7.4

As mentioned here, the problem happens because there is no bundler for the new ruby version. Running gem install bundler solves the issue.

christopher-dG commented 4 years ago

Having this issue with Julia 1.3.0-rcX (for X = 1:3). as well as 1.1.0-rc2. I've never had any issues with normal x.y.z versions.

heydonovan commented 4 years ago

I'm experiencing the same with the terraform plugin. This just started happening this week:

$ terraform version
asdf: No version set for command terraform
you might want to add one of the following in your .tool-versions file:

terraform 0.12.2
terraform 0.12.3
terraform 0.12.5
terraform 0.12.6
terraform 0.12.7
terraform 0.12.8
$ cat ~/.tool-versions
helm 2.9.1
terraform 0.12.13

Adding it to the file instructed has no effect.

webkay commented 4 years ago

In my case, there was an error when I tried gem install bundler

$ gem install bundler
asdf: No version set for command gem

But it was solved by asdf list-all and reinstall

asdf list-all ruby
asdf uninstall ruby 2.6.2
asdf install ruby 2.6.2
tispratik commented 4 years ago

I had the same issue after asdf upgrade from 0.7.0 to 0.7.5. Turns out that my shell's rc file was still pointing at the old version.

Before fix source /usr/local/Cellar/asdf/0.7.0/asdf.fish

After fix source /usr/local/Cellar/asdf/0.7.5/asdf.fish

yordis commented 4 years ago

When you google the problem and realized your answer is how you fix it: https://github.com/asdf-vm/asdf/issues/557#issuecomment-520164704 😆 😆 😆 😆 classic

Any updates on this?

Also, I am doing the following in my zsh

if [[ -f "$HOME/.asdf/asdf.sh" ]] then
  source "$HOME/.asdf/asdf.sh"
  source "$HOME/.asdf/completions/asdf.bash"
fi

Therefore, I don't think I am running into the issue that @tispratik ran into.

yordis commented 4 years ago

Something I found, doing asdf current

➜ asdf current
elixir         1.9.1    (set by /Users/ubi/.tool-versions)
erlang         22.0     (set by /Users/ubi/.tool-versions)
golang         1.13.5   (set by /Users/ubi/.tool-versions)
nodejs         version 6.10 is not installed for nodejs 
rust           1.28.0   (set by /Users/ubi/.tool-versions)

This is wrong

nodejs         version 6.10 is not installed for nodejs 

In fact I do have NodeJS specify in my .tool-versions

➜ cat ~/.tool-versions              
erlang 22.0
elixir 1.9.1
nodejs 10.17.0
ruby 2.6.3
clojure 1.10.0
golang 1.13.5
rust 1.28.0

I am not sure where 6.10 is coming from, continue the debugging.

yordis commented 4 years ago

Alright,

I changed ~/.asdfrc

➜ cat ~/.asdfrc 
legacy_version_file = no

I had yes before.

It seems that now asdf is able to pick ~/.tool-versions correctly now.

And I figured out somebody was using .nvmrc 🤷‍♂ 🤦‍♂

brock-noah commented 4 years ago

In relation to NodeJS, my issue was the globally installed yarn was for node v10 and not v12.

I was experiencing something like this even with the version specified.

➜ yarn
asdf: No version set for command yarn
you might want to add one of the following in your .tool-versions file:

nodejs 12.16.1

This path existed for my previous version of node 10 but not for node 12.

test -e ~/.asdf/installs/nodejs/12.16.1/.npm/lib/node_modules/yarn/ && echo OK || echo NOT FOUND

After asdf local nodejs 12.16.1 a npm install -g yarn resolved my issue.

pdgonzalez872 commented 4 years ago

Hi! I'm on OSX (Mojave 10.14.6) and ran into the following:

~ :> asdf version
v0.7.8-4a3e3d6
~ :> asdf current
elixir         1.9.4    (set by /Users/pdg/.tool-versions)
erlang         22.3.4.1 (set by /Users/pdg/.tool-versions)
~ :> asdf reshim
~ :> cat .tool-versions
erlang 22.3.4.1
elixir 1.9.4
~ :> iex
asdf: No preset version installed for command erl
Please install the missing version by running one of the following:

asdf install erlang 22.3.4.1

or add one of the following in your .tool-versions file:

erlang 22.0.7
erlang 22.2.8
~ :> asdf install erlang 22.3.4.1
erlang 22.3.4.1 is already installed
~ :> rm .tool-versions
~ :> echo "erlang 22.2.8
> elixir 1.9.4" > .tool-versions
~ :> cat .tool-versions
erlang 22.2.8
elixir 1.9.4
~ :> iex
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Interactive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C~ :>

Does anyone know how I can set the correct version on .tool-versions?

pdgonzalez872 commented 4 years ago

My issue above was solved here: https://github.com/asdf-vm/asdf/issues/662#issuecomment-643225916. Uninstall, use the correct plugin env vars and then installing it again solved my problem. I believe I had a bad install and had things in a weird state.

Thanks for helping @Stratus3D !

kaka-ruto commented 4 years ago

gem update --system solved for me

jthegedus commented 4 years ago

Is this considered resolved? If not, can someone please rehash the problem clearly for me as I cannot see anything in particular outstanding?

betogrun commented 4 years ago

It seems this happened because we forgot to add the packager manager (bundler for ruby, yarn for node) after adding a new version. I also wrote a post about this: http://blog.albertorocha.me/posts/asdf-ruby-no-version-set Hope it helps.

meymeynard commented 3 years ago

Also happened to me, solved it by just using

asdf reshim ruby
wliang002 commented 3 years ago

Set Current Version: resource: https://asdf-vm.com/#/core-manage-versions asdf global <name> <version> [<version>...] asdf shell <name> <version> [<version>...] asdf local <name> <version> [<version>...] global writes the version to $HOME/.tool-versions. shell set the version to an environment variable named ASDF_${LANG}_VERSION, for the current shell session only. local writes the version to $PWD/.tool-versions, creating it if needed.

asdf global elixir 1.2.4

amandaclarck commented 3 years ago

For me what it worked:

A mix of everything...

bbugh commented 3 years ago

This happened to me, and it turned out I forgot to set a version, which apparently writes to .tool-versions.

» asdf current
python          ______          No version set. Run "asdf <global|shell|local> python <version>"

» asdf global python 2.7.13
python          2.7.13          /Users/bbugh/.tool-versions

And then it worked.

jthegedus commented 3 years ago

Going to close this as there seems to be a consensus that this can be fixed by setting a version properly, reshim-ing ruby and/or installing the bundle gem.

pravin commented 3 years ago

I have the same issue. I tried the workarounds on this thread and they didn't help. Any suggestions?

prav@ubuntu:~/Projects/test$ asdf current
poetry          1.1.5           /home/prav/Projects/test/.tool-versions
python          2.7.18          /home/prav/Projects/test/.tool-versions
prav@ubuntu:~/Projects/test$ poetry new
No preset version installed for command python3
Please install a version by running one of the following:

asdf install python 2.7.18

or add one of the following versions in your config file at /home/prav/Projects/test/.tool-versions
python 3.9.4
prav@ubuntu:~/Projects/test$ asdf version
v0.8.0-c6145d0
prav@ubuntu:~/Projects/test$ asdf current
poetry          1.1.5           /home/prav/Projects/test/.tool-versions
python          2.7.18          /home/prav/Projects/test/.tool-versions
prav@ubuntu:~/Projects/test$ asdf reshim
prav@ubuntu:~/Projects/test$ poetry new
No preset version installed for command python3
Please install a version by running one of the following:

asdf install python 2.7.18

or add one of the following versions in your config file at /home/prav/Projects/test/.tool-versions
python 3.9.4
prav@ubuntu:~/Projects/test$
jthegedus commented 3 years ago

I have the same issue. I tried the workarounds on this thread and they didn't help. Any suggestions?

prav@ubuntu:~/Projects/test$ asdf current
poetry          1.1.5           /home/prav/Projects/test/.tool-versions
python          2.7.18          /home/prav/Projects/test/.tool-versions
prav@ubuntu:~/Projects/test$ poetry new
No preset version installed for command python3
Please install a version by running one of the following:

asdf install python 2.7.18

or add one of the following versions in your config file at /home/prav/Projects/test/.tool-versions
python 3.9.4
prav@ubuntu:~/Projects/test$ asdf version
v0.8.0-c6145d0
prav@ubuntu:~/Projects/test$ asdf current
poetry          1.1.5           /home/prav/Projects/test/.tool-versions
python          2.7.18          /home/prav/Projects/test/.tool-versions
prav@ubuntu:~/Projects/test$ asdf reshim
prav@ubuntu:~/Projects/test$ poetry new
No preset version installed for command python3
Please install a version by running one of the following:

asdf install python 2.7.18

or add one of the following versions in your config file at /home/prav/Projects/test/.tool-versions
python 3.9.4
prav@ubuntu:~/Projects/test$

try asdf reshim

pravin commented 3 years ago

try asdf reshim

Unfortunately didn't work (tried reshim in the pasted code above). Any other suggestions?

jthegedus commented 3 years ago

@pravin have you run asdf install python 2.7.18? 3.9.4 is found on your system, but not the version set in your .tool-versions file.

If that does not work and no suggestions in this thread solve the issue for you, can you open a new issue?

RobLoach commented 2 years ago

asdf global <plugin> latest fixed it for me.

willyjie23 commented 2 years ago

gem install rails --your_version fixed it for me.

surhidamatya commented 2 years ago

I faced the same issue for node what I did was

  1. Create .tool-versions in home directory
  2. asdf global nodejs 16.13.0

and it fixed the issue Note: I am using M1 Mac mini

ealasgarov commented 2 years ago

you need to set a version in a format "asdf global package-name 0.0.0"

oviliz commented 2 years ago

This is just rubbish...

dbrtly-upguard commented 2 years ago

I faced the same issue for node what I did was

  1. Create .tool-versions in home directory
  2. asdf global nodejs 16.13.0

and it fixed the issue Note: I am using M1 Mac mini

In my case it was direnv 2.32.1. Would help if there was a suggestion to append the global version file on install of a plugin.

Joseph-Burke commented 2 years ago

I'm facing the same issue after installing another ruby version with asdf.

$ asdf install ruby 2.4.3
$ asdf local ruby 2.4.3

$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]

$ cat .tool-versions 
ruby 2.4.3

$ bundle install
asdf: No version set for command bundle
you might want to add one of the following in your .tool-versions file:

ruby 2.6.1
ruby 2.6.3

Running asdf reshim ruby and restarted the terminal didn't fix the issue. asdf version is 0.7.4

As mentioned here, the problem happens because there is no bundler for the new ruby version. Running gem install bundler solves the issue.

This helped me get my solution. I was trying to run rails new, which only started working after gem install rails and gem install rails

trufan-poe commented 1 year ago

Has this problem with nodejs and yarn. I ran yarn install and got that error. Reinstalling yarn with asdf resolved the problem. The previous yarn I used was installed via npm.

liyicky commented 1 year ago

I had to uninstall the older version I was using in order to get things working again.


No preset version installed for command foreman
Please install a version by running one of the following:

asdf install ruby 3.1.2

or add one of the following versions in your config file at /Users/liyicky/.tool-versions
ruby 3.1.0

asdf uninstall ruby 3.1.0

fredrivett commented 1 year ago

For those that miss the obvious (like me), if you're trying to install dependencies with yarn then remember to actually install yarn for that version of node before trying to use it, with npm install -g yarn:

$ asdf install nodejs 16.3.0

$ yarn
> No preset version installed for command yarn
> Please install a version by running one of the following:
> asdf install nodejs 16.3.0
> or add one of the following versions in your config file at /[redacted]/.tool-versions
nodejs 16.18.1

$ node -v
> 16.3.0

$ npm install -g yarn

$ yarn
> // successfully installs
jthegedus commented 1 year ago

Just to add to what @fredrivett suggested, asdf has a plugin for Yarn, so your version of Yarn and Node.js can be managed independently instead of having to re-install yarn globally each time you change node version.

kenny-evitt commented 1 year ago

I ran into this issue (or rather a relative of it) just now with Node.js (and Gulp) and what seems to have worked was to run asdf reshim nodejs VERSION where VERSION is the (new) version I wanted to use:

✔ ~/my_code [my-branch|✚ 1] 
(ins)15:34 $ asdf shim-versions gulp
nodejs 6.11.4
nodejs 12.18.3
✔ ~/my_code [my-branch|✚ 1] 
(ins)15:34 $ asdf reshim nodejs 19.8.1
✔ ~/my_code [my-branch|✚ 1] 
(ins)15:35 $ asdf shim-versions gulp
nodejs 6.11.4
nodejs 12.18.3
nodejs 19.8.1
DRAKYULA commented 1 year ago

I ran into this issue and tried all of the above solutions, as well as some that my co-workers suggested, like removing ~/.asdf/shims. None of the above worked. Eventually, what seemed to work for me was removing the asdf ruby plugin (asdf plugin remove ruby), adding it back (asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git), and re-installing ruby (also gem install bundler and bundle install) and finally re-running the command I was trying to in the first place. Hopefully this helps someone in the future!

assadk88 commented 1 year ago

I ran into this issue and tried all of the above solutions, as well as some that my co-workers suggested, like removing ~/.asdf/shims. None of the above worked. Eventually, what seemed to work for me was removing the asdf ruby plugin (asdf plugin remove ruby), adding it back (asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git), and re-installing ruby (also gem install bundler and bundle install) and finally re-running the command I was trying to in the first place. Hopefully this helps someone in the future!

This was the only thing that worked for me too – thanks!

m-graf commented 1 year ago

For those that miss the obvious (like me), if you're trying to install dependencies with yarn then remember to actually install yarn for that version of node before trying to use it, with npm install -g yarn:

$ asdf install nodejs 16.3.0

$ yarn
> No preset version installed for command yarn
> Please install a version by running one of the following:
> asdf install nodejs 16.3.0
> or add one of the following versions in your config file at /[redacted]/.tool-versions
nodejs 16.18.1

$ node -v
> 16.3.0

$ npm install -g yarn

$ yarn
> // successfully installs

This is the only thing that worked. Comical.

LucasDachman commented 1 year ago

Uninstalling and reinstalling worked for me

asdf uninstall ruby 2.5.3
asdf install ruby 2.5.3
haider792 commented 10 months ago

if you working on CI/CD pipeline and facing ruby version issue, press "CMD + SHIFT + ." in your project folder on mac, you will see the hidden files after that you will be shown .ruby-version file, open it and update the version needed on the CI/CD. push the code in repo. everything will be good then

emmanuelkamala commented 8 months ago

In my case, there was an error when I tried gem install bundler

$ gem install bundler
asdf: No version set for command gem

But it was solved by asdf list-all and reinstall

asdf list-all ruby
asdf uninstall ruby 2.6.2
asdf install ruby 2.6.2

Thank you, this solved my problem!

jsatk commented 8 months ago

I am once again encountering this issue w/ ruby. I've tried everything here (reinstalls, reshims, restarts) still no dice.