Skip to content

Commit ccb05ac

Browse files
authored
Fix directory issue with fish launch script (#1015)
Fish doesn't have subshells, so `cd`ing within a command substitution will change the current working directory. When a directory-based version manager like `asdf` or `rtx` is used, the change in cwd could cause a different version of Elixir to run than that of the project. This fixes that potential issue by saving the current directory before calling the `readlink_f` function.
1 parent 196875c commit ccb05ac

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/launch.fish

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ function readlink_f
6262
end
6363

6464
if test -z "$ELS_INSTALL_PREFIX"
65+
set -l current_dir (pwd)
6566
set scriptpath (dirname (readlink_f (status -f)))
67+
68+
# readlink_f changes the current directory (since fish doesn't have
69+
# subshells), so it needs to be restored.
70+
cd $current_dir
6671
else
6772
set scriptpath $ELS_INSTALL_PREFIX
6873
end

0 commit comments

Comments
 (0)