Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How do I reset the $PATH variable on Mac OS X?

From what I can tell from reading other questions/answers is that my .bash_profile file may be corrupt. If I type

echo $PATH

in terminal the result is:

/usr/local/git/bin

From what I've read, that's not what the result is supposed to be. But I also can't get any of the commands (like edit or subl, for Sublime Text 2) to open the .bash_profile file to edit it. I was able to open the file in TextEdit using "cmd-shift-.", and here's what's in the file:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

PATH=$PATH:~/bin

export PATH

export PATH=/usr/local/git/bin

But the file is LOCKED, so I can't edit it there either. I'm very new to programming and in the middle of trying to install everything on my Mac to go through a Ruby on Rails tutorial. I can't even check my version of ruby, since even

ruby -v

returns

-bash: ruby: command not found

Any help would be greatly appreciated. Thanks.

share|improve this question

marked as duplicate by Nifle, Oliver Salzburg, soandos, slhck, Randolph West Jul 20 '12 at 18:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Adjust your question title because I'm pretty sure cd is working (is a shell built-in and needs no PATH) –  Matteo Jun 16 '12 at 7:15
add comment

3 Answers 3

up vote 5 down vote accepted

Temporarily fix the PATH, directly in the broken shell:

export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

(This is my PATH, it should mostly work for you as well)


Give yourself write permissions for that file, with or without fixing PATH as above:

/usr/bin/sudo /bin/chmod u+rwx /Users/yourusername/.bash_profile
/usr/bin/sudo /usr/sbin/chown yourusername /Users/yourusername/.bash_profile

Fix the PATH assignment in the last line to:

export PATH=/usr/local/git/bin:$PATH

Close your shell, and open a new one.

share|improve this answer
    
Sorry for such a basic question, but what exactly do you mean by "shell"? Is that the same thing as my running Terminal window? –  park Jun 16 '12 at 13:29
    
@park Shell is the software running within a Terminal window and tab that interprets your commands. In your case, it's called bash. –  Daniel Beck Jun 16 '12 at 13:34
    
Ah, thanks. The temporary fix worked in that shell to get commands like 'ls' working again (but not in a separate shell, so I guess that's why you called it temporary). For a permanent fix, is that where the next two lines of code you posted come in? The ones beginning with '/usr/bin/sudo'? I've heard that using 'sudo' you have to be very careful, and since I'm new to this I'm worried about messing something up. Should I just run those as two separate commands in Terminal? And finally, is the last line something I run as a 'export' command in terminal, or add to the .bash_profile txt file? –  park Jun 16 '12 at 13:45
    
@park Yes, after replacing the placeholder (yourusername appropriate). They'll make you the owner of that file and give yourself all permissions, since you mentioned it was "locked". After you can edit .bash_profile, change the last line to what I posted. This will no longer reset your PATH. –  Daniel Beck Jun 16 '12 at 13:48
    
Thanks! That seems to have worked and even subl works again to open text files in Sublime Text2. I just wish I knew how I messed up .bash_profile in the first place. –  park Jun 16 '12 at 14:04
show 2 more comments

i think you can try this thread to reset your $PATH! close the current terminal and start new one to make sure the changed settings are loaded!

share|improve this answer
    
If your answer entirely consists of a link to another question, then that's a good indicator this question should be closed as a duplicate of the other. –  slhck Jun 16 '12 at 6:52
add comment

Well I don't know if this will help but try:

PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

I'm also running mac and that is what occurs when i type echo $PATH which means you probably need these functions in terminal.

share|improve this answer
    
He's in bash, and that's not bash syntax. –  Daniel Beck Jun 16 '12 at 6:48
    
I knew he was in bash my mistake to forget to remove the $ but without the $ it would work –  gabe Jun 16 '12 at 7:00
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.