ChatGPT解决这个技术问题 Extra ChatGPT

How can I see the current value of my $PATH variable on OS X?

$ $PATH

returns:

-bash: /usr/local/share/npm/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin: No such file or directory

This seems quite ugly and might be giving me issues with getting Homebrew up and running as well.


H
HeatfanJohn

You need to use the command echo $PATH to display the PATH variable or you can just execute set or env to display all of your environment variables.

By typing $PATH you tried to run your PATH variable contents as a command name.

Bash displayed the contents of your path any way. Based on your output the following directories will be searched in the following order:

/usr/local/share/npm/bin
/Library/Frameworks/Python.framework/Versions/2.7/bin
/usr/local/bin
/usr/local/sbin
~/bin
/Library/Frameworks/Python.framework/Versions/Current/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/opt/X11/bin
/usr/local/git/bin

To me this list appears to be complete.


Thank you. I would greatly appreciate if you could checkout the other question listed. But thanks for the clarification on $PATH.
It's worth noting that the string that is returned from echo $PATH (or, in this case, just $PATH) acts more like an array, where each colon (":") is a separator between each entry. It's helpful to imagine a space (or, a new line) at each :.
p
paxdiablo

By entering $PATH on its own at the command prompt, you're trying to run it. This isn't like Windows where you can get your path output by simply typing path.

If you want to see what the path is, simply echo it:

echo $PATH

T
Temi Fakunle

To list out the paths as individual lines, you could use: echo "${PATH//:/\n}"


A
AlexSh

Use the command:

 echo $PATH

and you will see all path:

/Users/name/.rvm/gems/ruby-2.5.1@pe/bin:/Users/name/.rvm/gems/ruby-2.5.1@global/bin:/Users/sasha/.rvm/rubies/ruby-2.5.1/bin:/Users/sasha/.rvm/bin:


L
Lam Do

for MacOS, make sure you know where the GO install

export GOPATH=/usr/local/go
PATH=$PATH:$GOPATH/bin