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

Differences in PATH treatment between asdf and rtx using shims mode #1061

Closed
jylenhof opened this issue Dec 3, 2023 · 6 comments · Fixed by #1082
Closed

Differences in PATH treatment between asdf and rtx using shims mode #1061

jylenhof opened this issue Dec 3, 2023 · 6 comments · Fixed by #1082
Labels
bug Something isn't working

Comments

@jylenhof
Copy link
Contributor

jylenhof commented Dec 3, 2023

Describe the bug

Differences in PATH treatment between asdf and rtx using shims mode

To Reproduce

Config files :

jylenhof@pcportablejyl:~/toto$ cat .tool-versions 
python 3.9.18
shellcheck 0.9.0
shfmt 3.0.0
jylenhof@pcportablejyl:~/toto$ cat titi/tutu/.tool-versions 
shfmt 3.1.0
jylenhof@pcportablejyl:~/toto$ 

With asdf :

jylenhof@pcportablejyl:~/toto$ python
Python 3.9.18 (main, Dec  3 2023, 11:50:55) 
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print(os.environ['PATH'])
/home/jylenhof/.asdf/plugins/python/shims:/home/jylenhof/.asdf/installs/python/3.9.18/bin:/home/jylenhof/.asdf/shims:/home/jylenhof/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
>>> 
jylenhof@pcportablejyl:~/toto/titi/tutu$ python
Python 3.9.18 (main, Dec  3 2023, 11:50:55) 
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print(os.environ['PATH'])
/home/jylenhof/.asdf/plugins/python/shims:/home/jylenhof/.asdf/installs/python/3.9.18/bin:/home/jylenhof/.asdf/shims:/home/jylenhof/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
>>> 

With rtx :

jylenhof@pcportablejyl:~/toto$ python
Python 3.9.18 (main, Nov 26 2023, 01:24:46) 
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print (os.environ['PATH'])
/home/jylenhof/.local/share/rtx/installs/python/3.9.18/bin:/home/jylenhof/.local/share/rtx/installs/shellcheck/0.9.0/bin:/home/jylenhof/.local/share/rtx/installs/shfmt/3.0.0/bin:/home/jylenhof/.local/share/rtx/shims:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
>>>  
jylenhof@pcportablejyl:~/toto/titi/tutu$ python
Python 3.9.18 (main, Nov 26 2023, 01:24:46) 
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print(os.environ['PATH'])
/home/jylenhof/.local/share/rtx/installs/shfmt/3.1.0/bin:/home/jylenhof/.local/share/rtx/installs/python/3.9.18/bin:/home/jylenhof/.local/share/rtx/installs/shellcheck/0.9.0/bin:/home/jylenhof/.local/share/rtx/shims:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
>>> 

Expected behavior
asdf adds only python related paths (two additions) on python commands, rtx adds all tools path (shfmt, shellcheck, python) on python commands.
Is it a feature (should be written in documentation in the asdf section related, and perhaps explain why) or a bug (a correction has to be made) ?

rtx doctor output

rtx version:
  2023.12.5 linux-x64 (96d3ba0 2023-12-03)

build:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Sun, 3 Dec 2023 02:24:16 +0000
  Rust Version: rustc 1.74.0 (79e9716c9 2023-11-13)
  Profile: release

shell:
  /bin/bash
  GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
  Copyright (C) 2022 Free Software Foundation, Inc.
  Licence GPLv3+ : GNU GPL version 3 ou ultérieure <http://gnu.org/licenses/gpl.html>

  Ceci est un logiciel libre ; vous être libre de le modifier et de le redistribuer.
  AUCUNE GARANTIE n'est fournie, dans les limites permises par la loi.

rtx data directory:
  /home/jylenhof/.local/share/rtx

rtx environment variables:
  RTX_ENV=prod

settings:
  {"always_keep_download": "false", "always_keep_install": "false", "asdf_compat": "false", "disable_default_shorthands": "false", "disable_tools": "[]", "experimental": "true", "jobs": "4", "legacy_version_file": "true", "legacy_version_file_disable_tools": "[]", "log_level": "INFO", "missing_runtime_behavior": "warn", "plugin_autoupdate_last_check_duration": "10080", "raw": "false", "trusted_config_paths": "[]", "verbose": "true", "yes": "true"}

config files:
  /home/jylenhof/.config/rtx/config.toml
  /home/jylenhof/toto/.tool-versions
  /home/jylenhof/toto/titi/tutu/.tool-versions

plugins:
  bun          (core)
  deno         (core)
  go           (core)
  hub          https://github.com/vixus0/asdf-hub.git#b3cc81a
  java         (core)
  node         (core)
  python       (core)
  ruby         (core)
  shellcheck   https://github.com/luizm/asdf-shellcheck.git#b160a52
  shfmt        https://github.com/luizm/asdf-shfmt.git#a42c5ff
  tiny         https://github.com/rtx-plugins/rtx-tiny.git#df03b67

toolset:
  shfmt@3.1.0, python@3.9.18, shellcheck@0.9.0

No problems found

@jylenhof jylenhof added the bug Something isn't working label Dec 3, 2023
@jdx
Copy link
Owner

jdx commented Dec 3, 2023

this seems to be an XY problem, what is it you're attempting to do that isn't working? asdf will behave the same it just generates PATH entries when each shim is called but rtx is fast enough and can operate in parallel so it is cheap to simply do that calculation ahead of time regardless if it is needed

@jylenhofdecat
Copy link

jylenhofdecat commented Dec 4, 2023

Yes it makes a difference....Because both my terraform and python are operated by asdf/rtx

But my python in terraform is one fron .venv normally, but the PATH of the rtx python came first because it is happended at the beginning of PATH even if I call only terraform

@jylenhofdecat
Copy link

jylenhofdecat commented Dec 4, 2023

For asdf from within terraform call

/home/z01jlenh/.asdf/installs/terraform/1.3.6/bin:/home/z01jlenh/github/cpe-application-provisioning-system/cpe-application-provisioning-system/.venv/bin:/home/z01jlenh/.asdf/shims:/home/z01jlenh/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0/:/mnt/c/windows/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Users/Jean-Yves/AppData/Local/Microsoft/WindowsApps

@jylenhofdecat
Copy link

For rtx from with terraform call

/home/z01jlenh/.local/share/rtx/installs/terraform/1.3.6/bin:/home/z01jlenh/.local/share/rtx/installs/terraform-docs/0.16.0/bin:/home/z01jlenh/.local/share/rtx/installs/kubectl/1.22.2/bin:/home/z01jlenh/.local/share/rtx/installs/editorconfig-checker/2.6.0/bin:/home/z01jlenh/.local/share/rtx/installs/shfmt/3.5.1/bin:/home/z01jlenh/.local/share/rtx/installs/shellcheck/0.8.0/bin:/home/z01jlenh/.local/share/rtx/installs/flux2/2.1.1/bin:/home/z01jlenh/.local/share/rtx/installs/kustomize/5.0.3/bin:/home/z01jlenh/.local/share/rtx/installs/stern/1.26.0/bin:/home/z01jlenh/.local/share/rtx/installs/github-cli/2.35.0/bin:/home/z01jlenh/.local/share/rtx/installs/helm/3.12.3/bin:/home/z01jlenh/.local/share/rtx/installs/k9s/0.27.4/bin:/home/z01jlenh/.local/share/rtx/installs/bats/1.6.0/bin:/home/z01jlenh/.local/share/rtx/installs/python/3.10.13/bin:/home/z01jlenh/github/cpe-application-provisioning-system/cpe-application-provisioning-system/.venv/bin:/home/z01jlenh/.local/share/rtx/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0/:/mnt/c/windows/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Users/Jean-Yves/AppData/Local/Microsoft/WindowsApps

@jylenhofdecat
Copy link

Another little thing noticed when founding this :

Adding rtx shims to PATH with something like this in .bashrc is not completely proof :
export PATH="$HOME/.local/share/rtx/shims:$PATH"

Because when you call a shell in a shell you have twice this shims in the PATH

asdf has some tricks in the . "$HOME/.asdf/asdf.sh to avoid adding two times the shims

@jdx
Copy link
Owner

jdx commented Dec 4, 2023

what you're hitting is a variant of #863 which is that rtx should modify PATH in the place that the shims were inserted, not to the very front

jdx added a commit that referenced this issue Dec 5, 2023
Before, rtx would put the PATH entries at the front of PATH but that is too aggressive in some scenarios

Fixes #1061
@jdx jdx closed this as completed in #1082 Dec 5, 2023
jdx added a commit that referenced this issue Dec 5, 2023
* remove deprecated missing_runtime_behavior flag

* shims: insert rtx PATH entries just before the shim directory

Before, rtx would put the PATH entries at the front of PATH but that is too aggressive in some scenarios

Fixes #1061
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants