asdf icon indicating copy to clipboard operation
asdf copied to clipboard

fix: Remove static paths to asdf for shims

Open jrogov opened this issue 3 years ago • 5 comments

Summary

Switch from generating static paths to asdf exec file to using user's ASDF_DIR env variable to dynamically determine asdf location.

It ensures that regardless of updates for asdf installed on user system path won't rely on single correct path to asdf. Since the path might contain version number (e. g. /opt/homebrew/Cellar/asdf/0.9.0/libexec/bin/asdf), asdf installation would break as soon as new release is installed.

Fixes: #1231

jrogov avatar May 24 '22 13:05 jrogov

FYI: ran it on my machine, works as intended:

~/c/asdf (master) $ cat ~/.asdf/shims/erl
#!/usr/bin/env bash
# asdf-plugin: erlang 24.2.1
exec /Users/jrogov/code/asdf/bin/asdf exec "erl" "$@" # asdf_allow: ' asdf '

~/c/asdf (master) $ git checkout fix/static-asdf-paths-for-shims
Switched to branch 'fix/static-asdf-paths-for-shims'

~/c/asdf (fix/static-asdf-paths-for-shims) $ ASDF_DIR=$(pwd) ./bin/asdf reshim

~/c/asdf (fix/static-asdf-paths-for-shims) $ cat ~/.asdf/shims/erl
#!/usr/bin/env bash
# asdf-plugin: erlang 24.2.1
exec ${ASDF_DIR}/bin/asdf exec "erl" "$@" # asdf_allow: ' asdf '

~/c/asdf (fix/static-asdf-paths-for-shims) $ erl
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]

Eshell V12.2.1  (abort with ^G)

jrogov avatar May 24 '22 13:05 jrogov

Do we actually want to disable SC2016?

jthegedus avatar Jun 16 '22 14:06 jthegedus

Do we actually want to disable SC2016?

It looks like it's an exception to the rule, because we want the text ${ASDF_DIR} inside the shim. ie. We don't want ASDF_DIR expanded when reshimming as it is currently, instead we want ${ASDF_DIR} inside the shim itself so that it's expanded whenever the shim is executed. @jrogov Please correct me if I'm wrong here.

We might be able to keep SC2016 on this line by switching to double quotes and adding more escaping, but that's probably less readable.

doubledup avatar Jun 18 '22 13:06 doubledup

Is there some case where we need to expand ASDF_DIR when reshimming because ASDF_DIR isn't set when running a shim? I'm guessing not, given that the scripts that add asdf & the shims to PATH ensure that ASDF_DIR is set.

doubledup avatar Jun 18 '22 13:06 doubledup

Is there some case where we need to expand ASDF_DIR when reshimming because ASDF_DIR isn't set when running a shim? I'm guessing not, given that the scripts that add asdf & the shims to PATH ensure that ASDF_DIR is set.

Perhaps, someone (@doubledup or @jrogov) can see #531 and see what this change's impact might be?

jthegedus avatar Jun 21 '22 03:06 jthegedus

@jthegedus do we still want this change? If so I can investigate the issue above and update the PR based on what I find.

Stratus3D avatar Dec 29 '22 00:12 Stratus3D

@jthegedus do we still want this change? If so I can investigate the issue above and update the PR based on what I find.

I don't know if this is still necessary. I am not too familiar with this area of the code, how our other recent changes might affect this etc. If this is indeed a "fix", then it would be good to capture the scenario as a test case, so we don't cause regressions.

jthegedus avatar Dec 29 '22 01:12 jthegedus

Hey guys, sorry about completely falling of the radar, it's been busy 😄

I see that the issue was finally resolved in #1236, good job jthegedus!

Hence, I'm closing this one :slightly_smiling_face:

jrogov avatar Jan 12 '23 15:01 jrogov