Skip to content

bug: ASDF_DEFAULT_TOOL_VERSIONS_FILENAME env variable works so wired #1737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
siuyutpang opened this issue Apr 8, 2024 · 6 comments · May be fixed by #2101
Closed

bug: ASDF_DEFAULT_TOOL_VERSIONS_FILENAME env variable works so wired #1737

siuyutpang opened this issue Apr 8, 2024 · 6 comments · May be fixed by #2101
Labels

Comments

@siuyutpang
Copy link

Describe the Bug

I just don't want .tool-version clutter my home dir, So I set export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$XDG_CONFIG_HOME"/asdf/tool-versions in .zshrc file, Everything looks fine, but when i use asdf set global version, error occurs, but when i set export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.config/asdf/tool-versions, everything works well.

Steps to Reproduce

asdf global maven 3.9.6

Expected Behaviour

set correct global version for maven

Actual Behaviour

/opt/asdf-vm/lib/functions/versions.bash: line 78: /home/foobar//home/foobar/.config/asdf/tool-versions: No such file or directory

Environment

OS:
Linux arch 6.6.25-1-lts #1 SMP PREEMPT_DYNAMIC Fri, 05 Apr 2024 14:16:56 +0000 x86_64 GNU/Linux

SHELL:
zsh 5.9 (x86_64-pc-linux-gnu)

BASH VERSION:
5.2.26(1)-release

ASDF VERSION:
v0.14.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=/home/foobar/.config/asdf/tool-versions
ASDF_DATA_DIR=/home/foobar/.local/share/asdf
ASDF_DIR=/opt/asdf-vm
ASDF_CONFIG_FILE=/home/foobar/.config/asdf/asdfrc

ASDF INSTALLED PLUGINS:
maven                        https://github.com/halcyon/asdf-maven.git master 83fb4db

asdf plugins affected (if relevant)

No response

@siuyutpang siuyutpang added the bug label Apr 8, 2024
@VladaTrefil
Copy link

VladaTrefil commented May 9, 2024

I am experiencing the same issue.

For me the issue occurs with command: asdf local ruby 3.2.2

/opt/asdf-vm/lib/functions/versions.bash: line 78: /home/foorbar/path-to-current-directory//home/foobar/.config/asdf/tool-versions: No such file or directory

It seems like the path to current directory is added to the ASDF_DEFAULT_TOOL_VERSIONS_FILENAME.

Environment:

OS:
Linux  5.15.0-105-generic #115~20.04.1-Ubuntu SMP Mon Apr 15 17:33:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

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

BASH VERSION:
5.0.17(1)-release (x86_64-pc-linux-gnu)

ASDF VERSION:
failing with both v0.10.2 and v0.14.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=/home/foobar/.config/asdf/tool-versions
ASDF_DATA_DIR=/home/foobar/.local/share/asdf
ASDF_DIR=/opt/asdf-vm
ASDF_CONFIG_FILE=/home/foobar/.config/asdf/asdfrc

ASDF INSTALLED PLUGINS:
ruby                        https://github.com/asdf-vm/asdf-ruby

@ivuorinen
Copy link

I fell to the same rabbit hole when I started to use asdf.

ASDF_DEFAULT_TOOL_VERSIONS_FILENAME is the name you are using in all folders, like .nvmrc, not the path that defines the global tool versions.

I've been trying to get my $HOME tidy of all extra files, but it seems that global .tool-versions file should be located in $HOME/.tool-versions.

My solution was to symlink $HOME/.dotfiles/base/tool-versions to $HOME/.tool-versions. It's not as clean as I'd like, but seems to work.

@xavbourdeau
Copy link

In fact you misinterpret the ASDF_DEFAULT_TOOL_VERSIONS_FILENAME value (like I did for few hours). The environment variable manage only the file name, not the full path... Once you understand that you better understand why you have "/anyfolder//folder-you-wish/.tool-versions" in the error message.

So to fix that I use

WORKDIR /opt ,

Then

source /opt/asdf/asdf.sh
asdf plugin-add "${plugin}"
asdf install 
asdf global "${plugin}"

And finally, to avoid sourcing asdf (which is totaly unuseful after the command above) just add

PATH="/opt/asdf/shims:xxxx"

And bash will find your asdf bin automatically

@Stratus3D
Copy link
Member

Would it be better if this environment variable was named ASDF_TOOL_VERSIONS_DEFAULT_FILENAME?

We need to make it clear to users that it sets the default filename and not the default .tool-versions file itself.

I've been trying to get my $HOME tidy of all extra files, but it seems that global .tool-versions file should be located in $HOME/.tool-versions.

My solution was to symlink $HOME/.dotfiles/base/tool-versions to $HOME/.tool-versions. It's not as clean as I'd like, but seems to work.

@ivuorinen I think this will eventually be handled by #687

@ivuorinen
Copy link

Awesome! That will indeed fix the problem I was experiencing!

And the renaming of the env would really help with the confusion. 👍 from me!

@Stratus3D
Copy link
Member

This is fixed by #2101. It will go out in the next patch release as it's backward compatible. I expect the next release to be tagged about a month from now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants