Skip to content

Commit 1ba706d

Browse files
committed
do not overwrite user environment variables on asdf 0.16+
1 parent 68e6414 commit 1ba706d

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

scripts/launch.fish

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# First order of business, see whether we can setup asdf
1010

1111
echo "Looking for asdf install" >&2
12-
test -n "$ASDF_DIR"; or set ASDF_DIR "$HOME/.asdf"
1312

1413
# Check if we have the asdf binary for version >= 0.16.0
1514
set asdf (which asdf)
@@ -18,18 +17,17 @@ if test -n "$asdf"
1817
set semver (string match -r '(\d+)\.(\d+)\.(\d+)' $asdf_version)
1918
if test $semver[2] -eq 0 -a $semver[3] -lt 16
2019
# Fallback to old method for asdf version <= 0.15.x
20+
test -n "$ASDF_DIR"; or set ASDF_DIR "$HOME/.asdf"
2121
set ASDF_SH "$ASDF_DIR/asdf.fish"
2222
echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" >&2
2323
# Source the old asdf.sh script for versions <= 0.15.0
2424
source "$ASDF_SH"
2525
else
26-
echo "asdf executable found at $asdf. Setting ASDF_DIR=$ASDF_DIR and adding $ASDF_DIR/shims to PATH." >&2
27-
# If the binary is found, set up environment for newer asdf versions
28-
set -gx ASDF_DATA_DIR "$ASDF_DIR"
29-
set -gx PATH "$ASDF_DATA_DIR/shims" $PATH
26+
echo "asdf executable found at $asdf. Using ASDF_DIR=$ASDF_DIR, ASDF_DATA_DIR=$ASDF_DATA_DIR." >&2
3027
end
3128
else
3229
# Fallback to old method for asdf version <= 0.15.x
30+
test -n "$ASDF_DIR"; or set ASDF_DIR "$HOME/.asdf"
3331
set ASDF_SH "$ASDF_DIR/asdf.fish"
3432
if test -f "$ASDF_SH"
3533
echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" >&2

scripts/launch.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ esac
3737

3838
# First order of business, see whether we can setup asdf
3939
echo "Looking for asdf install" >&2
40-
ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
4140

4241
# Check if we have the asdf binary for version >= 0.16.0
4342
if command -v asdf >/dev/null 2>&1; then
@@ -47,6 +46,7 @@ if command -v asdf >/dev/null 2>&1; then
4746
minor=$(echo "$version" | cut -d. -f2)
4847
# If the version is less than 0.16.0 (i.e. major = 0 and minor < 16), use legacy method.
4948
if [ "$major" -eq 0 ] && [ "$minor" -lt 16 ]; then
49+
ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
5050
ASDF_SH="${ASDF_DIR}/asdf.sh"
5151
if test -f "$ASDF_SH"; then
5252
>&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
@@ -56,13 +56,11 @@ if command -v asdf >/dev/null 2>&1; then
5656
>&2 echo "Legacy asdf not found at $ASDF_SH"
5757
fi
5858
else
59-
>&2 echo "asdf executable found at $(command -v asdf). Setting ASDF_DIR=${ASDF_DIR} and adding ${ASDF_DIR}/shims to PATH."
60-
# If the binary is found, set up environment for newer asdf versions
61-
export ASDF_DATA_DIR="$ASDF_DIR"
62-
export PATH="$ASDF_DATA_DIR/shims:$PATH"
59+
>&2 echo "asdf executable found at $(command -v asdf). Using ASDF_DIR=${ASDF_DIR}, ASDF_DATA_DIR=${ASDF_DATA_DIR}."
6360
fi
6461
else
6562
# Fallback to old method for version <= 0.15.x
63+
ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
6664
ASDF_SH="${ASDF_DIR}/asdf.sh"
6765
if test -f "$ASDF_SH"; then
6866
>&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"

0 commit comments

Comments
 (0)