asdf-vm / asdf-elixir

Elixir plugin for asdf version manager
https://github.com/asdf-vm/asdf
MIT License
473 stars 70 forks source link

Old shim scripts are not compatible with asdf 0.9.0 (or latest Homebrew?) #110

Closed ymtszw closed 2 years ago

ymtszw commented 2 years ago

After upgrading my brew-installed asdf to 0.9.0 on macOS Monterey, this started to happen:

$ mix
/Users/yumatsuzawa/.asdf/shims/mix: line 3: /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf: No such file or directory
/Users/yumatsuzawa/.asdf/shims/mix: line 3: exec: /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf: cannot execute: No such file or directory

At this time the environment was:

The errored shim script was:

#!/usr/bin/env bash
# asdf-plugin: elixir 1.12.3-otp-24
exec /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf exec "mix" "$@"

As shown, it explicitly targets to versioned path of asdf. And if a shim script exists, it will be reused after installing another version of the language so this problem lingers like:

#!/usr/bin/env bash
# asdf-plugin: elixir 1.12.3-otp-24
# asdf-plugin: elixir 1.13.0-otp-24
exec /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf exec "mix" "$@"

OTOH, asdf-managed shim script from another language (example of asdf-nodejs) is like this:

#!/usr/bin/env bash
# asdf-plugin: nodejs 16.13.0
# asdf-plugin: nodejs 16.13.1
exec /opt/homebrew/opt/asdf/libexec/bin/asdf exec "node" "$@"

...which does NOT depend on explicitly-versioned path.

I have no idea whether this is a change in behavior of asdf, asdf-elixir or Homebrew, but anyway the old script not works any more since Homebrew only keeps latest version of a formula (therefore Cellar/asdf/0.8.1_1/ path is gone after brew upgrade asdf).

I don't know this affects many people but let me drop a record.

The workaround is (1) asdf plugin-remove elixir (deleting old shim scripts), (2) reinstall with asdf plugin-add elixir, then (3) reinstall versions of languages you are using. Since apparently, the latest asdf-elixir correctly places asdf-version-agnostic shim scripts when freshly invoked.

Detecting old shim scripts and upgrading them to the latest format would be definitely an improvements if possible. However at least some documentation would be nice if it can find somewhere suitable (or I may be overlooking already existing one?).

P.S. asdf-erlang was on exactly the same situation.

Stratus3D commented 2 years ago

Thank you for report. I think this is a duplicate of https://github.com/asdf-vm/asdf/issues/1115, and not an issue with asdf-elixir but rather asdf itself. I am closing this issue, please continue the conversation on https://github.com/asdf-vm/asdf/issues/1115. If there is something I've missed here let me know and I can re-open the ticket.

Also appears related to https://github.com/asdf-vm/asdf/issues/1122.