简体   繁体   中英

Adding directory to PATH on Mac

I'm trying to add a directory to my path, and I'm having trouble. I have a Macbook Pro running Mac OS X Lion 10.7.5 . To make the changes I used the command:

open ~/.bash_profile

It opened up the profile file and it looked like this:

export PATH=${PATH}:/Users/Banderson/android-sdks/tools 
export PATH=${PATH}:/Users/Banderson/android-sdks/platform-tools 
#
# Your previous /Users/Banderson/.bash_profile file was backed up as /Users/Banderson/.bash_profile.macports-saved_2012-05-16_at_09:53:57
##

# MacPorts Installer addition on 2012-05-16_at_09:53:57: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.


[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

# Setting PATH for JRuby 1.7.0.RC1
# The orginal version is saved in .bash_profile.jrubysave
PATH="${PATH}:/Library/Frameworks/JRuby.framework/Versions/Current/bin"
export PATH

Then I added this:

   export PATH=${PATH}:/Users/Banderson/Documents/awstats-7.1/wwwroot/cgi-bin/

To make the .bash_profile look like this:

export PATH=${PATH}:/Users/Banderson/android-sdks/tools 
export PATH=${PATH}:/Users/Banderson/android-sdks/platform-tools 
export PATH=${PATH}:/Users/Banderson/Documents/awstats-7.1/wwwroot/cgi-bin/
#
# Your previous /Users/Banderson/.bash_profile file was backed up as /Users/Banderson/.bash_profile.macports-saved_2012-05-16_at_09:53:57
##

# MacPorts Installer addition on 2012-05-16_at_09:53:57: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.


[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

# Setting PATH for JRuby 1.7.0.RC1
# The orginal version is saved in .bash_profile.jrubysave
PATH="${PATH}:/Library/Frameworks/JRuby.framework/Versions/Current/bin"
export PATH

After I added that, I saved it, then in the terminal, I executed the source ~/.bash_profile command, quit the terminal window, started a new window, and tried to launch a file from the directory I added to the path, but it didn't work. Can someone please tell me what I'm doing wrong and how I can fix it?

EDIT:

Here is what echo $PATH returns:

/Users/Banderson/.rvm/gems/jruby-1.6.8/bin:/Users/Banderson/.rvm/gems/jruby-1.6.8@global/bin:/Users/Banderson/.rvm/rubies/jruby-1.6.8/bin:/Users/Banderson/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/Banderson/android-sdks/tools:/Users/Banderson/android-sdks/platform-tools:/Users/Banderson/Documents/awstats-7.1/wwwroot/cgi-bin/:/Library/Frameworks/JRuby.framework/Versions/Current/bin

Your problem seems to be the inclusion of the rvm scripts. I guess, there your path is overwritten.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM