asdf-vm/asdf

bug: fish path set-up breaks fish_add_path

tjvc opened this issue · 4 comments

tjvc commented

Describe the Bug

The fish set-up script sets fish_user_paths as a global variable. This breaks the expected behaviour of this variable, which is a universal variable by default. Universal variables persist across fish sessions; global variables are specific to the current session. Global variables, when present, take precedence over universal variables of the same name. The impact of this is that users calling fish_add_path /some/path unexpectedly find that the assignment is not persisted across sessions.

This has previously been raised as an issue on fish itself, and noted as a comment on another issue in this repo, but I think it's deserving of its own issue.

Steps to Reproduce

  1. Install the asdf fish set-up script
  2. Start a fish shell
  3. Update fish_user_paths with fish_add_path /some/path
  4. Start another fish shell

Expected Behaviour

The path assignment is persisted across sessions.

Actual Behaviour

The path assignment is only applied in the current session.

Environment

OS:
Darwin XX379KM0VT 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64

SHELL:
fish, version 3.6.0

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
v0.12.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/thom/.asdf
ASDF_DIR=/opt/homebrew/Cellar/asdf/0.12.0/libexec
ASDF_CONFIG_FILE=/Users/thom/.asdfrc

ASDF INSTALLED PLUGINS:
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c9e5df4
python                       https://github.com/danhper/asdf-python.git master 8505457
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 16bc8ac
terraform                    https://github.com/asdf-community/asdf-hashicorp.git master c44c314

asdf plugins affected (if relevant)

No response

I am in the same boat. Just stumbled on this thread today. I am new to fish so working through and figuring out what is going on is going to take time. Would appreciate if you do end up finding a solution, if you share it.

samvv commented

I can confirm this is an issue. I had to remove asdf from my system because of this.

tjvc commented

I am in the same boat. Just stumbled on this thread today. I am new to fish so working through and figuring out what is going on is going to take time. Would appreciate if you do end up finding a solution, if you share it.

@richjdsmith, in case this is useful to you six weeks later, I workaround this behaviour by adding the asdf paths manually in my fish config file before sourcing the set-up script:

fish_add_path "$ASDF_DIR/bin"
fish_add_path "$HOME/.asdf/shims"

if status --is-interactive && type -q asdf
  source (brew --prefix asdf)/libexec/asdf.fish
end

This works because asdf first checks whether these paths are present before setting the global variable. Ideally it wouldn't be necessary.

Closed by #1699