0

I have a Go binary (called AssetFinder) that I want to add to my $PATH so that I can autocomplete it. The binary is at the location /Users/spike/go/bin and I can execute it by cding to that directory and running ./assetfinder but I don't want to cd to this directory every time I want to use this tool. So I tried to addd the path of this tool to my $PATH variable as well as update the ~/.bash_profile too.

I found a similar question and I tried to see if the $PATH variable is updated and here's what echo $PATH | tr ':' '\n' gives me

/home/spike/go/bin
/usr/local/go/bin
/Users/spike/Library/Android/sdk/tools
/Users/spike/Library/Android/sdk/platform-tools
/Users/spike/Library/Android/sdk/build-tools/28\.0\.3
/usr/local/Cellar/git/2.6.1/bin
/home/spike/go/bin
/usr/local/go/bin
/Users/spike/Library/Android/sdk/tools
/Users/spike/Library/Android/sdk/platform-tools
/Users/spike/Library/Android/sdk/build-tools/28\.0\.3
/usr/local/Cellar/git/2.6.1/bin
/usr/local/Cellar/git/2.6.1/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/VMware Fusion.app/Contents/Public
/usr/local/go/bin
/opt/X11/bin
/Users/spike/Library/Android/sdk/tools
/Users/spike/Library/Android/sdk/platform-tools
/Users/spike/Library/Android/sdk/build-tools/28.0.3
/usr/local/go/bin
/home/spike/go/bin

So the $PATH variable points to the right directory for the binary but when I give the command assetfinder, I get an error saying -bash: assetfinder: command not found

My mac currently runs Big Sur and my login shell is /bin/bash (and not /bin/zsh)

Can anyone please tell me the right way to go about adding this to $PATH so that autocomplete works properly?

  • 2
    It looks like you added /home/spike/go/bin instead of /Users/spike/go/bin. Also, the escapes in 28\.0\.3 will prevent it from working, and your adds are getting run multiple times (not really a problem, but not as clean as it could be). – Gordon Davisson Aug 31 '21 at 01:45
  • 1
    ‍♂️

    That was indeed the problem. If you can add it to the answer, I'd be happy to accept it

    – Spike Spiegel Aug 31 '21 at 01:53
  • I don't think @GordonDavisson will get a notification unless you mention them. – unbeatable101 Sep 04 '21 at 21:28
  • You have your path being set in some file that's being executed every time you start a subshell, that's why your path is repeating like that. – Marc Wilson Sep 22 '21 at 22:58

0 Answers0