Skip to content
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

bug: .tool-versions in home is not applied as global #1860

Closed
alvaroico opened this issue Jan 30, 2025 · 10 comments · Fixed by #1883
Closed

bug: .tool-versions in home is not applied as global #1860

alvaroico opened this issue Jan 30, 2025 · 10 comments · Fixed by #1883
Labels

Comments

@alvaroico
Copy link

Describe the Bug

I had to apply .tool-versions to / and not to ~/ - "/home/user"

To fix this I copied .tool-versions from ~/ to /, making it the same as the global version

Steps to Reproduce

rodar algum comando em um nivel fora da home

cd ..

Expected Behaviour

Recognize ~/.tool-versions as the system-wide default

Actual Behaviour

is not logging in lower level folder outside ~/ so accepting commands inside /home/user

Environment

alvaroico in ~
❯ asdf info
OS:
Linux Bilu 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

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

BASH VERSION:
5.2.21(1)-release

ASDF VERSION:
v0.16.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/alvaroico/.asdf
ASDF_CONFIG_FILE=/home/alvaroico/.asdfrc

ASDF INSTALLED PLUGINS:
bun         https://github.com/cometkim/asdf-bun.git              019058c3a9f408a06bab63a4a3782c555a8dde3c
deno        https://github.com/asdf-community/asdf-deno.git       13f7f08c93989fdc0b372e78df226e511fc13fa9
dotnet-core https://github.com/emersonsoares/asdf-dotnet-core.git 4583e4b87b48d39e37ed0acbf54481297d6b4992
elixir      https://github.com/asdf-vm/asdf-elixir.git            ea842831ae39417f2dfe7b96fb0c3cc573314aa6
erlang      https://github.com/asdf-vm/asdf-erlang.git            0e617b61ece7cff73331aacc1cd9986e35618c41
flutter     https://github.com/oae/asdf-flutter.git               d73606641938341b8b17bd3e2859a5267bb89bd0
golang      https://github.com/asdf-community/asdf-golang.git     e2527a31714da7bc671a684308579f4ef8863281
java        https://github.com/halcyon/asdf-java.git              7c7ce22c2dc1ce084aa23d6aec60698e73dc9046
nodejs      https://github.com/asdf-vm/asdf-nodejs.git            93bd217ba74f05080eebb7d8e1c146a385b01d7f
php         https://github.com/asdf-community/asdf-php.git        52c669a77f08ec81caff47d560476d2ba1b176b9
python      https://github.com/danhper/asdf-python.git            a3a01856098d6d2b9642e382f5b38e70275726d1
ruby        https://github.com/asdf-vm/asdf-ruby.git              059cdee5b02c5a5569a5858e2a379f84dbdb95d7
rust        https://github.com/code-lever/asdf-rust.git           95acf4fe65df1de74fca502482b8f3ac5af73c05
alvaroico in ~cd ..
alvaroico in /home 
❯ asdf info
OS:
Linux Bilu 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

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

BASH VERSION:
5.2.21(1)-release

ASDF VERSION:
v0.16.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/alvaroico/.asdf
ASDF_CONFIG_FILE=/home/alvaroico/.asdfrc

ASDF INSTALLED PLUGINS:
bun         https://github.com/cometkim/asdf-bun.git              019058c3a9f408a06bab63a4a3782c555a8dde3c
deno        https://github.com/asdf-community/asdf-deno.git       13f7f08c93989fdc0b372e78df226e511fc13fa9
dotnet-core https://github.com/emersonsoares/asdf-dotnet-core.git 4583e4b87b48d39e37ed0acbf54481297d6b4992
elixir      https://github.com/asdf-vm/asdf-elixir.git            ea842831ae39417f2dfe7b96fb0c3cc573314aa6
erlang      https://github.com/asdf-vm/asdf-erlang.git            0e617b61ece7cff73331aacc1cd9986e35618c41
flutter     https://github.com/oae/asdf-flutter.git               d73606641938341b8b17bd3e2859a5267bb89bd0
golang      https://github.com/asdf-community/asdf-golang.git     e2527a31714da7bc671a684308579f4ef8863281
java        https://github.com/halcyon/asdf-java.git              7c7ce22c2dc1ce084aa23d6aec60698e73dc9046
nodejs      https://github.com/asdf-vm/asdf-nodejs.git            93bd217ba74f05080eebb7d8e1c146a385b01d7f
php         https://github.com/asdf-community/asdf-php.git        52c669a77f08ec81caff47d560476d2ba1b176b9
python      https://github.com/danhper/asdf-python.git            a3a01856098d6d2b9642e382f5b38e70275726d1
ruby        https://github.com/asdf-vm/asdf-ruby.git              059cdee5b02c5a5569a5858e2a379f84dbdb95d7
rust        https://github.com/code-lever/asdf-rust.git           95acf4fe65df1de74fca502482b8f3ac5af73c05
alvaroico in /home 

asdf plugins affected (if relevant)

Image

@alvaroico alvaroico added the bug label Jan 30, 2025
@Stratus3D
Copy link
Member

Hi @alvaroico , did you experience this issue on earlier versions of asdf?

@alvaroico
Copy link
Author

Hi @alvaroico , did you experience this issue on earlier versions of asdf?

In versions prior to v0.16.0, the error does not occur.

This happens because the system may not recognize the global version for directories located before the user's home (~/).

In other words, programs installed in /opt, for example, may not detect the presence of Node.js or PHP.

@n-rodriguez
Copy link
Contributor

n-rodriguez commented Jan 30, 2025

Hi there! I have the same kind of error when installing Ruby (which uses Rust to compile it's internal JIT) :

building Rust YJIT (release mode)
No version is set for command rustc
Consider adding one of the following versions in your config file at /tmp/ruby-build.20250130213132.2471.si17Lg/ruby-3.4.1/.tool-versions
rust 1.83
make[1]: *** [yjit/yjit.mk:26: yjit/target/release/libyjit.a] Error 126
OS:
Linux cloud 6.1.0-30-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.124-1 (2025-01-12) x86_64 GNU/Linux

SHELL:
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

BASH VERSION:
5.2.15(1)-release

ASDF VERSION:
v0.16.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/data/nicolas/.asdf
ASDF_CONFIG_FILE=/data/nicolas/.asdfrc

ASDF INSTALLED PLUGINS:
bombardier https://github.com/NeoHsu/asdf-bombardier.git          46bea4d29d44a1578f7114bef0c86bfe9bbc3ee9
crystal    https://github.com/asdf-community/asdf-crystal.git     7af37cf7b63ad0c3c176a1e740b2d0919f41f054
earthly    https://github.com/YR-ZR0/asdf-earthly.git             58c78cb8b7b61e5b68f00714d0c8739f93cb5590
golang     https://github.com/asdf-community/asdf-golang.git      e2527a31714da7bc671a684308579f4ef8863281
k3d        https://github.com/spencergilbert/asdf-k3d.git         5b0e5b9209bf0e1e8f83cbd912e8cccfe31e7fe2
kompose    https://github.com/technikhil314/asdf-kompose.git      2706fa5579473c50aeb79c6098c7797ea96eb64c
kubectl    https://github.com/asdf-community/asdf-kubectl.git     2fb3b57090e3efe55953a751a134c271ba83b119
mkcert     https://github.com/salasrod/asdf-mkcert.git            8287d3c115b6c681592f44b2060973af6ae24be3
nodejs     https://github.com/asdf-vm/asdf-nodejs.git             93bd217ba74f05080eebb7d8e1c146a385b01d7f
overmind   https://github.com/virtualstaticvoid/asdf-overmind.git abaee0622091883c16f25cf860f19b0f3a2b639c
python     https://github.com/danhper/asdf-python.git             a3a01856098d6d2b9642e382f5b38e70275726d1
ruby       https://github.com/asdf-vm/asdf-ruby.git               059cdee5b02c5a5569a5858e2a379f84dbdb95d7
rust       https://github.com/code-lever/asdf-rust.git            95acf4fe65df1de74fca502482b8f3ac5af73c05
shellcheck https://github.com/luizm/asdf-shellcheck.git           66200ffa221fc75d7b28103f53326db6e721d08f
skaffold   https://github.com/nklmilojevic/asdf-skaffold.git      bf2f9922ddfc4d8613a2d92f3fedc458464e36e6
squarectl  https://github.com/jbox-web/asdf-squarectl.git         5c0621cf4d1402c06cff70734c22a8c0f227198c
tokei      https://github.com/gasuketsu/asdf-tokei.git            d127410f0e4acf56b2e8070108df8a3847047fc6
yarn       https://github.com/twuni/asdf-yarn.git                 376c5407ef22c82fa56e4bd9f6a9108354063acb
yq         https://github.com/sudermanjr/asdf-yq.git              772992f66c49fe681b1cd02d14e8166930472bf1

Rust 1.83 is declared globally :

asdf list rust
 *1.83
rustc --version
rustc 1.83.0 (90b35a623 2024-11-26)

It was working well with asdf 0.15

@agreedSkiing
Copy link

agreedSkiing commented Jan 31, 2025

Noticed the same with java and maven.

Trying to find java on a new ubuntu installation.

> where java
/usr/bin/java
/bin/java

~
> which java
/usr/bin/java

~
> ls java
"java": No such file or directory (os error 2)

~
> asdf which java
/home/eriase/.asdf/installs/java/oracle-21.0.2/bin/java

~
> java --version
Picked up JAVA_TOOL_OPTIONS: -DargLine=-Dhttp.proxyHost=proxy.digg.se -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.digg.se -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=*.digg.se|*.sgit.*|localhost|127.0.0.1
openjdk 21.0.5 2024-10-15
OpenJDK Runtime Environment (build 21.0.5+11-Ubuntu-1ubuntu124.04)
OpenJDK 64-Bit Server VM (build 21.0.5+11-Ubuntu-1ubuntu124.04, mixed mode, sharing)

~
> mvn
zsh: command not found: mvn

~
> asdf set --home maven 3.9.8

~
> mvn
zsh: command not found: mvn

~
> asdf set maven 3.9.8

~
> mvn
zsh: command not found: mvn

~
> exec zsh

~
> mvn
zsh: command not found: mvn

~ 8s
> bat .tool-versions
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: .tool-versions
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ java oracle-21.0.2
   2   │ maven 3.9.8
   3   │ nodejs 20.18.1
   4   │ neovim 0.10.4
   5   │ golang 1.23.4
───────┴──────────────────

Asdf info

OS:
Linux DI-001000155089 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

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

BASH VERSION:
5.2.21(1)-release

ASDF VERSION:
v0.16.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/eriase/.asdf
ASDF_CONFIG_FILE=/home/eriase/.asdfrc

ASDF INSTALLED PLUGINS:
golang    https://github.com/asdf-community/asdf-golang.git e2527a31714da7bc671a684308579f4ef8863281
java      https://github.com/halcyon/asdf-java.git          22504c2eb7e9ff6dc26506620419a56953362079
maven     https://github.com/halcyon/asdf-maven.git         583612baaa031ca1ef4cf73185c51bb0fcc52daf
neovim    https://github.com/richin13/asdf-neovim.git       ff05a09a7df71c064da08ffb0b9316a09d1ae7fa
nodejs    https://github.com/asdf-vm/asdf-nodejs.git        93bd217ba74f05080eebb7d8e1c146a385b01d7f

P.S. This worked with the v0.15.0

@agreedSkiing
Copy link

agreedSkiing commented Jan 31, 2025

So, i just tried to set/add the shims folder to my path and that fixed it.

~
> export PATH="$HOME/.asdf/shims:${PATH}"

~
> mvn
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.077 s
[INFO] Finished at: 2025-01-31T16:23:39+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

~
> java --version
java 21.0.2 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)

~
> mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: /home/eriase/.asdf/installs/maven/3.9.8
Java version: 21.0.2, vendor: Oracle Corporation, runtime: /home/eriase/.asdf/installs/java/oracle-21.0.2
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.167.4-microsoft-standard-wsl2", arch: "amd64", family: "unix"

@agreedSkiing
Copy link

Sorry forgot to add the tmp folder where i had another .tools-versions

~/tmp
> asdf install java oracle-21.0.6
######################################################################## 100.0%
jdk-21.0.6_linux-x64_bin.tar.gz
jdk-21.0.6_linux-x64_bin.tar.gz: OK
asdf%

~/tmp 24s
> asdf set java oracle-21.0.6

~/tmp
> java --version
java 21.0.6 2025-01-21 LTS
Java(TM) SE Runtime Environment (build 21.0.6+8-LTS-188)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.6+8-LTS-188, mixed mode, sharing)

~/tmp
> mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: /home/eriase/.asdf/installs/maven/3.9.8
Java version: 21.0.2, vendor: Oracle Corporation, runtime: /home/eriase/.asdf/installs/java/oracle-21.0.2
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.167.4-microsoft-standard-wsl2", arch: "amd64", family: "unix"

~/tmp
> exec zsh

 .. enable proxy environment variables ..

~/tmp
> mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: /home/eriase/.asdf/installs/maven/3.9.8
Java version: 21.0.6, vendor: Oracle Corporation, runtime: /home/eriase/.asdf/installs/java/oracle-21.0.6
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.167.4-microsoft-standard-wsl2", arch: "amd64", family: "unix"

~/tmp
> bat .tool-versions
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: .tool-versions
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ java oracle-21.0.6
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@jn-jairo
Copy link
Contributor

jn-jairo commented Feb 1, 2025

I have the same problem, the ~/.tool-versions is not accepted as a global, it just looks up the folders for a .tool-versions file but my project is in another hard drive, even though it is linked inside the home folder it doesn't find the .tool-versions, it is probably expanding the path to the absolute path.

Accepting the ~/.tool-versions as a global fallback would be better, to keep the same behavior as the old versions.

@mkungla
Copy link
Contributor

mkungla commented Feb 2, 2025

The issue arises when looking up .tool-versions in a mount point other than $HOME is mounted, causing it to fail when trying to detect global versions defined in $HOME/.tool-versions.

Currently, when a drive is mounted (e.g., to /ssd) and a tool is used, ASDF looks for .tool-versions in the root of that filesystem. If no .tool-versions is found there, it fails. The expected behavior is for ASDF to fall back and check $HOME/.tool-versions in this scenario.

@Stratus3D
Copy link
Member

I'm working on a fix for this now. It may take me a day or two to get merged, but once merged I'll be immediately releasing a patch version.

Stratus3D added a commit that referenced this issue Feb 4, 2025
* Use version in home dir when no version found in root dir
* Correct `FindExecutable` function so returns `NoVersionSetError` even when `.tool-version` file located
* Update `resolve` and `versions` package tests to use test plugin name

Fixes #1860
@Stratus3D
Copy link
Member

I'm going to do some testing and then tag a patch release tonight with the fix for this.

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.

6 participants