sam_r
sam_r

Reputation: 53

.bash_profile wrecks my PATH, but .bashrc

i've been using .bashrc (happily) for a long time, but when i tried to add export PATH="/Users/sam/bin/android-sdk-macosx/platform-tools/" to my path, it wouldn't work... i figured i'd add it to a .bash_profile file, but whenever i run my terminal with .bash_profile, no commands work not ls and none of the commands i put in my .bash_profile path. i would continue to use .bashrc, but another script (one that i shouldn't edit) uses adb, and i can't get .bashrc to see it for some reason.. (adb is in /Users/sam/bin/android-sdk-macosx/platform-tools/

what should i do?

Upvotes: 1

Views: 377

Answers (2)

fredtantini
fredtantini

Reputation: 16586

You have to add the /Users/.../ path to your already existing $PATH

export PATH="${PATH}:/Users/sam/bin/android-sdk-macosx/platform-tools/"

Your command says the $PATH variable will only be 1 "folder" /Users/.... But $PATH is in fact already defined and used. So you have to concatenate the new "folder" to the list of folders in $PATH. If you do echo $PATH you will see this list.

If you want to add more than 1 path, you can still do that in one expression:

export PATH="${PATH}:/Users/sam/bin/android-sdk-macosx/platform-tools/:/Users/sam/bin/:/a/third/addition/"

Upvotes: 3

gomerudo
gomerudo

Reputation: 171

It seems like you are completely overriding the value of PATH. By default PATH contains references to the binary files, which includes the commands. As you are forcing the value of PATH without preserving the current value your terminal is not finding any other than

"/Users/sam/bin/android-sdk-macosx/platform-tools/"

When modifying the path variable it's recommended to do it in the next way - at least you are sure that the forced value won't break the shell:

PATH=$PATH:New_Reference  # Colon is the separator of the values
export PATH

Upvotes: 1

Related Questions