asdf: `asdf help` does not work with Homebrew installation

Steps to reproduce

  • brew install asdf
  • asdf or asdf help

Expected behavior

Should list help text for asdf

Actual behavior

cat: /usr/local/VERSION: No such file or directory
version:

cat: /usr/local/help.txt: No such file or directory

"Late but latest"
-- Rajinikanth

Environment

OS: macOS 10.14.6

asdf version: 0.75

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 22
  • Comments: 22 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@januswel Thanks for reporting.

Your reproduction doesn’t follow all of the asdf setup instructions. Namely, you need to add asdf to your shell as well.

# install
brew install asdf
# add to shell       <-- commonly missed setup step
. $(brew --prefix asdf)/asdf.sh
# restart your shell <-- commonly missed setup step
# run asdf command
asdf

Can you confirm this occurs after all the setup steps are complete?

Thank you @jthegedus It works after adding . $(brew --prefix asdf)/asdf.sh

@jthegedus

I am going to be updating the docs soon to better communicate that it is a multi-step process as most homebrew users hit this issue.

It’s very nice!! I have added some changes to show install instructions for the Homebrew formula

https://github.com/Homebrew/homebrew-core/pull/54315

Feel free to close and create another PR to improve in your way 🙇

you don’t need to restart the shell (for those of you have like 20 open)

just include this line

. $(brew --prefix asdf)/asdf.sh

into your .*rc file (I’m using zshrc on this box at the time)

ie:

echo ". $(brew --prefix asdf)/asdf.sh" >> $HOME/.zshrc # (or .bashrc depending on which shell you are using)

and then do this:

source ~/.zshrc
~ % asdf help
version: v0.7.8

MANAGE PLUGINS
  asdf plugin add <name> [<git-url>]       Add a plugin from the plugin repo OR, add a Git repo
                                           as a plugin by specifying the name and repo url
  asdf plugin list [--urls] [--refs]       List installed plugins. Optionally show git urls and git-ref.
  asdf plugin list all                     List plugins registered on asdf-plugins repository with URLs
  asdf plugin remove <name>                Remove plugin and package versions
  asdf plugin update <name> [<git-ref>]    Update a plugin to latest commit or a particular git-ref.
  asdf plugin update --all                 Update all plugins


MANAGE PACKAGES
  asdf install [<name> <version>]          Install a specific version of a package or,
                                           with no arguments, install all the package
                                           versions listed in the .tool-versions file
  asdf uninstall <name> <version>          Remove a specific version of a package
  asdf current                             Display current version set or being used for all packages
  asdf current <name>                      Display current version set or being used for package
  asdf where <name> [<version>]            Display install path for an installed or current version
  asdf which <command>                     Display the path to an executable
  asdf shell <name> <version>              Set the package version in the current shell
  asdf local <name> <version>              Set the package local version
  asdf global <name> <version>             Set the package global version
  asdf list <name>                         List installed versions of a package
  asdf list all <name>                     List all versions of a package


UTILS
  asdf exec <command> [args..]             Executes the command shim for current version
  asdf env <command> [util]                Runs util (default: `env`) inside the environment used for command shim execution.
  asdf reshim <name> <version>             Recreate shims for version of a package
  asdf shim-versions <command>             List on which plugins and versions is command available
  asdf update                              Update asdf to the latest stable release
  asdf update --head                       Update asdf to the latest on the master branch

"Late but latest"
-- Rajinikanth

@vic Yeah, I can try and find some time to work on this.

@jthegedus I kinda screwed up by responding all over the place, so I wrote a response https://github.com/asdf-vm/asdf/issues/891#issuecomment-799400852 and will be following up there if that’s ok.

To follow up, the reason this fails, as @deiga said here is based on how Homebrew is linking the files when doing a prefix.install https://github.com/asdf-vm/asdf/issues/607#issuecomment-560447230

That’s the problem since you’re scattering scripts that depend on relative paths to source each other. If anyone is interested, I’ve added a fix to the formula https://github.com/Homebrew/homebrew-core/pull/73173 that puts everything in a single folder without linking them, and makes a symlink to the binary under /usr/local/bin/asdf. Now this means that ASDF_DATA_DIRand ASDF_USER_SHIMS aren’t set and shims aren’t under your $PATH That’s two things.

For the first matter, asdf should (and seem) to be coded with such manner that $HOME/.asdf is the default values for anywhere it expects $ASDF_DATA_DIR - though it mixes between checking a variable and using a function for that look up.

For the second matter, users just have to add export PATH="${$HOME/.asdf/shim}:$PATH"

This is better, as you’re simply just adding binaries to your path just like any other, instead of loading some script.

Obviously you can still load your script as the documentation currently states, just have to change the path .

source $(brew --prefix asdf)/libexec/asdf.sh

On v0.7.8, this issue still appears

re-pro steps are here

brew install asdf
# or
brew install asdf --HEAD

asdf

It seems to work with the latest version of asdf (v0.7.7 at the time of writing):

> which asdf
/usr/local/opt/asdf/bin/asdf

> realpath $(which asdf)
/usr/local/Cellar/asdf/0.7.7/bin/asdf

> asdf help
version: v0.7.7

MANAGE PLUGINS
  asdf plugin add <name> [<git-url>]       Add a plugin from the plugin repo OR, add a Git repo
                                           as a plugin by specifying the name and repo url
  asdf plugin list [--urls] [--refs]       List installed plugins. Optionally show git urls and git-ref.
  asdf plugin list all                     List plugins registered on asdf-plugins repository with URLs
  asdf plugin remove <name>                Remove plugin and package versions
  asdf plugin update <name> [<git-ref>]    Update a plugin to latest commit or a particular git-ref.
  asdf plugin update --all                 Update all plugins


MANAGE PACKAGES
  asdf install [<name> <version>]          Install a specific version of a package or,
                                           with no arguments, install all the package
                                           versions listed in the .tool-versions file
  asdf uninstall <name> <version>          Remove a specific version of a package
  asdf current                             Display current version set or being used for all packages
  asdf current <name>                      Display current version set or being used for package
  asdf where <name> [<version>]            Display install path for an installed or current version
  asdf which <command>                     Display the path to an executable
  asdf shell <name> <version>              Set the package version in the current shell
  asdf local <name> <version>              Set the package local version
  asdf global <name> <version>             Set the package global version
  asdf list <name>                         List installed versions of a package
  asdf list all <name>                     List all versions of a package


UTILS
  asdf exec <command> [args..]             Executes the command shim for current version
  asdf env <command> [util]                Runs util (default: `env`) inside the environment used for command shim execution.
  asdf reshim <name> <version>             Recreate shims for version of a package
  asdf shim-versions <command>             List on which plugins and versions is command available
  asdf update                              Update asdf to the latest stable release
  asdf update --head                       Update asdf to the latest on the master branch

"Late but latest"
-- Rajinikanth

@vic That weirdness comes from the fact, that the Homebrew formula links all directories in the asdf repo and this line https://github.com/asdf-vm/asdf/blob/master/bin/asdf#L4

In the meantime you could use the bin/asdf from the real location where asdf was installed by homebrew.