Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version command fails on macOS after first installation #428

Closed
dmlemos opened this issue Jan 15, 2019 · 23 comments
Closed

Version command fails on macOS after first installation #428

dmlemos opened this issue Jan 15, 2019 · 23 comments
Labels

Comments

@dmlemos
Copy link

dmlemos commented Jan 15, 2019

Steps to reproduce

$ brew install asdf

Follow instructions from #425

$ asdf version

Expected behavior

asdf should display program version

Actual behavior

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

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

Environment

OS: macOS 10.14.2

asdf version: 0.6.2

@ttilberg
Copy link

I am having this issue as well using homebrew. I suspect this function is not working as expected when running from brew

asdf_dir() {

While looking into this a bit more, I found that
${BASH_SOURCE[0]} evaluates to /usr/local/lib/utils.sh which seems a bit odd, as it's not namespaced in any way. utils.sh seems a bit generic to be in a generic lib dir. I'm not familiar with brew's expectations and linking strategy, but everything else in this dir is named according to it's package.

image

So ultimately what is happening is:

 asdf_dir() {
   if [ -z "$ASDF_DIR" ]; then
     local current_script_path=${BASH_SOURCE[0]}
     # => /usr/local/lib/utils.sh

     export ASDF_DIR
     ASDF_DIR=$(cd "$(dirname "$(dirname "$current_script_path")")" || exit; pwd)
    # `dirname dir` returns the parent directory -- so we end up with
    # => /usr/local/lib/utils.sh  --> /usr/local/lib --> /usr/local
   fi

   echo "$ASDF_DIR"
 }

As a temporary workaround, you can set the env var ASDF_DIR using brew --prefix

$ export ASDF_DIR=$(brew --prefix asdf)

Or, to save the startup time from evaluating the brew command, just hardcode the value in. It looks pretty stable. (for me, /usr/local/opt/asdf)

Until this is fixed, you should add this line to your ~/.bash_profile.

@dboune
Copy link
Contributor

dboune commented Mar 13, 2019

This appears to have been fixed, along with a few other things.

asdf version: 0.7.0 installed via homebrew

Running asdf version or asdf --version produced no error.

# .bash_profile

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

I am not setting or exporting ASDF_DIR manually.

$ echo $ASDF_DIR
/usr/local/opt/asdf

bash completions work out of the box, no need to source manually (if you have either followed the homebrew instructions for bash completion, or have properly installed the bash-completion or bash-completion@2 packages)

When listing/installing plugins, data is placed in ~/.asdf/

Working nicely for this new asdf user.

@heydonovan
Copy link

Just installed asdf, and I'm running into this issue as well:

$ brew upgrade asdf
Error: asdf 0.7.0 already installed
$ asdf --version
cat: /usr/local/VERSION: No such file or directory
$ cat ~/.asdf/asdf.fish
cat: /Users/heydonovan/.asdf/asdf.fish: No such file or directory

@danhper
Copy link
Member

danhper commented Mar 26, 2019

@heydonovan Could you show us the line you added to .bash_profile (or other init file) please?

@heydonovan
Copy link

Sure! Here is what I have. I think I ran into similar issues with asdf back in the day as well. It's almost as if it assumes a git clone was ran, and the appropriate config files were created. Where as installing it using brew install asdf just never seems to work for me.

$ cat ~/.config/fish/config.fish
set PATH ~/.virtualenv/bin/ $PATH
alias k="kubectl"
alias ll="exa -lah --color never"
alias vim="nvim"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
pyenv init - | source
set fish_greeting
$ asdf version
cat: /usr/local/VERSION: No such file or directory
version:

cat: /usr/local/help.txt: No such file or directory
$ cat ~/.bash_profile
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

@jsatk
Copy link
Contributor

jsatk commented Apr 12, 2019

I'm in the same boat as @heydonovan.

@AaronLasseigne
Copy link

I had the same issue and was able to fix it by sourcing the homebrew install location. I add this to my config.fish.

source (brew --prefix asdf)/asdf.fish

Other shells should be able to use a similar solution.

@jsatk
Copy link
Contributor

jsatk commented May 3, 2019

@AaronLasseigne great follow up.

I forgot that I posted in here and have since found a solution. The above snippet posted by @AaronLasseigne doesn't quite work for my. My asdf isn't living directly in the (brew --prefix) directory.

Here's what I have in my config.fish.

set --local BREW_PREFIX (brew --prefix)

[ -f $BREW_PREFIX/opt/asdf/asdf.fish ]
and source $BREW_PREFIX/opt/asdf/asdf.fish

@jlamberg
Copy link

jlamberg commented Jun 5, 2019

I am having this same issue with 0.7.2 (macOS 10.14.4 + Bash), too.

The Actual behavior from the OP is what I see no matter which asdf command I try to run.

Adding source `brew --prefix asdf`/asdf.sh to my .bash_profile solved the problem.

Anyone else having this same issue with any asdf command? If yes, should the title for this issue be changed to something more generic than related to only the version command?

@jakeonrails
Copy link

This should probably be fixed by the brew installer. I came here because the very first thing I tried after installing via $ brew install asdf was simply $ asdf and got this error message. I use ZSH. Maybe it's handled for Bash? There's a thing in the brew installer about adding some line to your .bash_profile for completions, but I would only do that if I wanted completions. I expect/(hope for) the brew installation to just work.

@jagdishadusumalli
Copy link

I encountered the same error and was due to wrong initialiser command in the wrong rc file
I am on macOS 14.4.5, asdf 0.7.2,zsh with on_my_zsh, using asdf via homebrew
What worked for me

brew install asdf
echo -e '\n. $(brew --prefix asdf)/asdf.sh' >> ~/.zshrc (instead of bash_profile)

restart terminal

@ivanhoe
Copy link

ivanhoe commented Jul 8, 2019

I encountered the same error and was due to wrong initialiser command in the wrong rc file
I am on macOS 14.4.5, asdf 0.7.2,zsh with on_my_zsh, using asdf via homebrew
What worked for me

brew install asdf
echo -e '\n. $(brew --prefix asdf)/asdf.sh' >> ~/.zshrc (instead of bash_profile)

restart terminal

It works for me @jagdishadusumalli thanks so much!! what's happening the scenes?

lucasnar pushed a commit to lucasnar/dotfiles that referenced this issue Aug 12, 2019
gvlekke pushed a commit to gvlekke/dotfiles that referenced this issue Dec 17, 2019
@sun-mir
Copy link

sun-mir commented Feb 14, 2020

Just to follow up on this...

Seems like this was just clarified in official docs, i.e. #428 (comment) is part of the doc now.
No fix is expected here either from brew or from asdf

brew install asdf
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.bash_profile
# for Catalina and/or Zsh: 
# echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zprofile
Install asdf (click to expand)

https://asdf-vm.com/#/core-manage-asdf-vm?id=install-asdf-vm
image

@jthegedus
Copy link
Contributor

jthegedus commented Feb 15, 2020

Hi all, I will add another section for Catalina since macOS now defaults to zsh and this can cause confusion. this was already done, however not visually clear.

However, if the step of adding asdf to your shell's profiles is skipped then it will not work as expected. I'm unsure how the Brew package is managed, but for user experience if we can get it to modify the profile with the correct brew dir then that would be preferred.

I am looking into documentation site improvements to make the 2 steps be displayed more succinctly and only the instructions you need for your usage to be display. Thanks for the feedback all 🙏

@raphaklaus
Copy link

If you don't care about installing it via Git and don't want to rewrite the ASDF_DIR env var and do some workarounds, just go for Git installation.

@jthegedus
Copy link
Contributor

jthegedus commented Apr 22, 2020

We've again updated the documentation to further remove confusion on setup of the various combinations of OS, Shell and Install Method (see https://asdf-vm.com/#/core-manage-asdf-vm?id=install-asdf-vm). I believe this should remove the confusion for future asdf users.

Given that adding the correct asdf setup script to the correct rc file was the primary issue discussed here I am marking this issue as solved.

Please open an new issue should anyone discover further issues. Thanks for your time reporting and helping one another.

@johnwyles
Copy link

johnwyles commented Sep 1, 2020

I also had to chmod 755 $(brew --prefix asdf)/asdf.sh for ZSH (ie. ~/.zshrc)

@tveon
Copy link

tveon commented Jan 19, 2021

How about add these instructions to the homebrew formula? I.e. shown under "caveats".

@jthegedus
Copy link
Contributor

jthegedus commented Jan 24, 2021

@tveon I have tried to get these into caveats of the Homebrew formula, see #785 - the Homebrew maintainers say it isn't a "caveat" and our documentation site should detail the steps. Needless to say, our docs do share this information, the Homebrew workflow has trained people to not lookup the documentation for the tools they install, they expect Homebrew to do it all. Since we don't want asdf to modify shell configs this is the position we find ourselves in.

@glenjamin
Copy link

glenjamin commented Feb 16, 2021

the Homebrew maintainers say it isn't a "caveat" and our documentation site should detail the steps

Is there a homebrew issue where that was discussed (I looked but didn't find it)? A brief survey of other version-swiching tools shows that they all include their add-to-shell instructions in the Caveat field, so this seems at best inconsistent - and seemingly quite user-hostile.

Do you think the maintainers would be pursuaded by a list of prior art in other homebrew formulae?

@Stratus3D
Copy link
Member

@jthegedus do you have a link to the discussion with Homebrew maintainers? I can't find it.

@jthegedus
Copy link
Contributor

jthegedus commented Feb 16, 2021

In #785 there's an expandable section which links to the discussion on the hombrew-core repo - this is that link Homebrew/homebrew-core#54315 - the linked issues piling up on the PR shows that this is an issue and comes up a lot, but were told it's not valid use of caveats.

@espen
Copy link

espen commented Dec 6, 2021

I had to reinstall asdf + asdf-ruby and then reinstall rubies to fix this. I was running 0.9 but shims was pointing to 0.8.1_1 dir. No changes in dotfiles required for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests