asdf is not using version from local legacy file

Created on 18 Feb 2019  路  6Comments  路  Source: asdf-vm/asdf

Steps to reproduce

Install asdf 0.6.3
Run asdf plugin-add ruby
Create a directory with a .ruby-version file and a ruby version VERSION specified
Run asdf install ruby VERSION

Expected behavior

ruby -v should give VERSION

Actual behavior

ruby -v gives version from default ~/.tool-versions

Environment

OS: Fedora

asdf version: 0.6.3

The problem disappears when I downgrade to asdf 0.6.2 and reshim ruby.
Since I can fix the problem by downgrading, I thought this might be a asdf problem, but maybe it's related to asdf-ruby.

bug

Most helpful comment

This is also occurring for me, after upgrading to asdf from v0.6.2 to v0.7.0 (via homebrew). It doesn't look like it's just applicable to asdf-ruby, as asdf also appears to be ignoring my local .nvmrc file

$ echo $SHELL
/usr/local/bin/fish

$ fish --version
fish, version 3.0.2

$ asdf --version
v0.7.0

$ cat ~/.tool-versions
elixir 1.8.1-otp-21
nodejs 11.10.0
postgres 11.2
redis 3.2.12
ruby 2.6.1
erlang 21.2.6

$ cd ~/Dev/my_app

$ cat ~/.asdfrc
legacy_version_file = yes

$ cat ./.ruby-version
2.3.7

$ cat ./.nvmrc
6.11.5

$ asdf current 
elixir         1.8.1-otp-21 (set by /Users/rick/.tool-versions)
erlang         21.2.6   (set by /Users/rick/.tool-versions)
nodejs         6.11.5   (set by /Users/rick/Dev/my_app/.nvmrc)
postgres       11.2     (set by /Users/rick/.tool-versions)
redis          3.2.12   (set by /Users/rick/.tool-versions)
ruby           2.3.7    (set by /Users/rick/Dev/my_app/.ruby-version)

$ /usr/bin/which ruby
/Users/rick/.asdf/shims/ruby

$ /usr/bin/which node
/Users/rick/.asdf/shims/node

$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

$ node --version
v11.10.0

All 6 comments

This is also occurring for me, after upgrading to asdf from v0.6.2 to v0.7.0 (via homebrew). It doesn't look like it's just applicable to asdf-ruby, as asdf also appears to be ignoring my local .nvmrc file

$ echo $SHELL
/usr/local/bin/fish

$ fish --version
fish, version 3.0.2

$ asdf --version
v0.7.0

$ cat ~/.tool-versions
elixir 1.8.1-otp-21
nodejs 11.10.0
postgres 11.2
redis 3.2.12
ruby 2.6.1
erlang 21.2.6

$ cd ~/Dev/my_app

$ cat ~/.asdfrc
legacy_version_file = yes

$ cat ./.ruby-version
2.3.7

$ cat ./.nvmrc
6.11.5

$ asdf current 
elixir         1.8.1-otp-21 (set by /Users/rick/.tool-versions)
erlang         21.2.6   (set by /Users/rick/.tool-versions)
nodejs         6.11.5   (set by /Users/rick/Dev/my_app/.nvmrc)
postgres       11.2     (set by /Users/rick/.tool-versions)
redis          3.2.12   (set by /Users/rick/.tool-versions)
ruby           2.3.7    (set by /Users/rick/Dev/my_app/.ruby-version)

$ /usr/bin/which ruby
/Users/rick/.asdf/shims/ruby

$ /usr/bin/which node
/Users/rick/.asdf/shims/node

$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

$ node --version
v11.10.0

Having the same issue with .ruby-version files on MacOS High Sierra since upgrading asdf to 0.7.0 via Homebrew. Seems like it's only respecting the .tool-versions file, rather than the legacy files.

Same problem here. env, which, and exec commands differ by looking up through the file hierarchy for .tool-versions files, _then_ looking up through the hierarchy for legacy version files. In my case my $HOME/.tool-versions was taking precedence over any other .ruby-version files ($HOME/.tool-versions respected before $HOME/project/.ruby-version). My fix was to remove $HOME/.tool-versions and instead rely entirely on legacy version files (.ruby-version, .node-version, ...).

Same problem here. env, which, and exec commands differ by looking up through the file hierarchy for .tool-versions files, _then_ looking up through the hierarchy for legacy version files. In my case my $HOME/.tool-versions was taking precedence over _any_ other .ruby-version files ($HOME/.tool-versions respected before $HOME/project/.ruby-version). My fix was to remove $HOME/.tool-versions and instead rely entirely on legacy version files (.ruby-version, .node-version, ...).

That worked well for me. I also found that you can still use a ~/.ruby-version file to set the global ruby version.

I think this is something to do with tool_versions() at https://github.com/asdf-vm/asdf/blob/master/lib/utils.sh#L592 not going looking for legacy files.

find_tool_versions() at https://github.com/asdf-vm/asdf/blob/master/lib/utils.sh#L383 only goes looking for the specific .tool-versions file.

GitHub magic comment failed to autoclose this issue after https://github.com/asdf-vm/asdf/pull/484 landed. The mentionned PR fixed this issue for me.

For those facing this issue, you can do asdf update --head to get the fix while waiting for 0.7.1 to be released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quintasan picture Quintasan  路  5Comments

niksfirefly picture niksfirefly  路  3Comments

Antiarchitect picture Antiarchitect  路  3Comments

robsonpeixoto picture robsonpeixoto  路  4Comments

johnjelinek picture johnjelinek  路  3Comments