asdf-vm / asdf-vm/asdf

Improve fish setup

Open
#1,346 6 comments 5 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Go
Stars
25.6k
Forks
941
Avg merge
9h 24m
Merged PRs (30d)
3

Description

### Is your feature request related to a problem? Please describe

The current way that the `asdf.fish` script works is not very "fish-like":
- It is not necessary to loop over `$PATH` to make sure the `.asdf` folders are not duplicated; we can just use the built-in `fish_add_path` function for it.
- It is not necessary to always check the path on every single run, since fish already persists the path in the file `.config/fish/fish_variables` when running `fish_add_path`.
- Admittedly, future changes made by the user may break asdf, but rerunning `fish_add_path` is a safe way to make sure the path is in the right order.
- Loading the asdf wrapper function can be done by symlinking to `.config/fish/functions` instead, as a one-time setup step.

I recently ran into a problem where Ruby was using the system-provided `bundle` gem, instead of asdf; reshim did not help, and restarting the shell did not help either, as the current wrapper was not correctly prepending the folders to PATH.

### Describe the proposed solution

We can replace the current script with a setup file, run only once, that modifies the path and symlinks the files.

Roughly speaking, we only need 3 lines, plus a few extra to define the right variables:

```
fish_add_path --move $ASDF_DIR/bin
fish_add_path --move $ASDF_DATA_DIR/shims
ln -s $ASDF_DIR/lib/asdf.fish ~/.config/fish/functions/asdf.fish
```

Running this once is enough, it will be persisted without modifying `.config/fish/config.fish`.
Future issues related to this can safely be fixed by rerunning this code.

We can replace the current wrapper with an `asdf_setup.fish` file, keeping the first half where we get the right variables, adding the lines above, and change fish instructions to tell users to just run the file once.

This will also keep the user's `.config/fish/config.fish` file clean.

### Describe similar `asdf` features and why they are not sufficient

When using the existing fish script, the shims path was somehow put at the end of PATH, breaking my intended Ruby installation until I manually fixed it.
Rerunning the script by restarting the fish changed nothing, a manual fix was needed.

### Describe other workarounds you've considered

Modifying the script as said above, without the symlink, and using it as it is now (a simple wrapper) should still work.

Still, after looking at how fish handles configuration and functions, I consider it more appropriate to run this script only once instead, and let fish handle the specifics.

Contributor guide

Open the contributing guide

Research direction

Start by locating the current asdf.fish script and the fish setup instructions, then compare them with the proposed asdf_setup.fish flow and the .config/fish/functions location. Check how fish_add_path persists entries in .config/fish/fish_variables and verify the setup in a fresh fish session. Done means the setup runs once, preserves the intended PATH order, symlinks the wrapper, and leaves config.fish unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
fish, shell
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.