Asdf: -bash: asdf: command not found

Created on 2 Oct 2016  路  9Comments  路  Source: asdf-vm/asdf

I made all steps - installed all packages for Mac OS and updated .bash_profile, but have:

-bash: asdf: command not found

Most helpful comment

The error happens because the binary you are trying to call from command line is only part of the current user's PATH variable, but not a part of root user's PATH.

You can verify this by locating the path of the binary you are trying to access. In my case I was trying to call "bettercap-ng". So I ran,

$ which bettercap-ng

output: /home/user/work/bin/bettercap

I checked whether this location is part of my root user's PATH.

$ sudo env | grep ^PATH

output: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

So sudo cannot find the binary that I am trying to call from commandline. Hence returns the error command not found.

You can direct sudo to use the current user's PATH when calling a binary like below.

$ sudo -E env "PATH=$PATH" [command] [arguments]

In fact, one can make an alias out of it:

$ alias mysudo='sudo -E env "PATH=$PATH"'

It's also possible to name the alias itself sudo, replacing the original sudo.

Please refer to this video for step by step solution

All 9 comments

@TiSer
Thank you for reporting this. I think I found a similar issue with a colleague's computer last week. Most likely has to do with bash sessions. Can you check what is your $PATH and ping back?

If there is some junk output like saving sessions... polluting the $PATH var, try out this quick solution: touch $HOME/.bash_sessions_disable

If you let me know that is the issue, I'll look into a fix/work-around to make that permanent from within asdf itself.

@HashNuke
No, my $PATH var is ok.

$ $PATH
-bash: /Users/tiser/.asdf: is a directory

This was happening to me because the echo instructions append to the end of your bash_profile. If you don't have a newline at the end of your bash_profile, it appends it directly onto the end of the file - causing confusion in bash.

Instead of giving people echos for installation, you might write a small bash script that adds the lines onto the file in a nicer way, that way it can make sure its surrounding with newline, etc.

Also, a minor annoyance is that the added scripts drop me off in root rather than my user folder when term opens. I added a simple cd ~ to the end of my bash, but the script probably shouldn't do that.

@HashNuke @DaveSanders I created with a possible solution to @DaveSanders' issue. Adding a newline to the beginning of the strings we echo will prevent that from happening.

@Stratus3D Thank you ~! Merged the PR.

Sorry to post in a long closed issue (google brought me here). I am experiencing this issue exactly as stated by TiSer. Everything looks good but 'asdf: command not found'

$PATH shows -bash: /Users/rory/.asdf: is a directory

Looks like a great tool. Would love to try it out.

As mentioned above, please double check you do have a new line at the end of your .bashrc or .bash_profile.
If this does not work for you, could you paste the relevant part the file please?

@rorykoehler how did you install asdf? And what version did you install? I have not had any trouble with the latest version.

The error happens because the binary you are trying to call from command line is only part of the current user's PATH variable, but not a part of root user's PATH.

You can verify this by locating the path of the binary you are trying to access. In my case I was trying to call "bettercap-ng". So I ran,

$ which bettercap-ng

output: /home/user/work/bin/bettercap

I checked whether this location is part of my root user's PATH.

$ sudo env | grep ^PATH

output: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

So sudo cannot find the binary that I am trying to call from commandline. Hence returns the error command not found.

You can direct sudo to use the current user's PATH when calling a binary like below.

$ sudo -E env "PATH=$PATH" [command] [arguments]

In fact, one can make an alias out of it:

$ alias mysudo='sudo -E env "PATH=$PATH"'

It's also possible to name the alias itself sudo, replacing the original sudo.

Please refer to this video for step by step solution

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robsonpeixoto picture robsonpeixoto  路  4Comments

michalmuskala picture michalmuskala  路  5Comments

tomsquest picture tomsquest  路  4Comments

Antiarchitect picture Antiarchitect  路  3Comments

johnjelinek picture johnjelinek  路  3Comments