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.

I was trying to install jhbuild earlier as part of a GTK+ install, and ran the command alias jhbuild="PATH=gtk-prefix/bin:$PATH jhbuild". Since then, I haven't been able to access many important services (including Homebrew and MacPorts), since, obviously, the $PATH variable has been changed.

Here's the problem: when I try to reset the $PATH variable to the default one (found by running echo $PATH on my other machine, also running OS X 10.8, whose $PATH hasn't been modified), I get this error message:

-bash: alias: `/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin': invalid alias name

What can be done to undo the modified $PATH alias?

EDIT: Running $PATH (not echo $PATH) on the machine presenting the issue returns

/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin: No such file or directory

EDIT: Running echo $PATH gives

/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin

Which gives the same thing as running $PATH, but without the error message.

EDIT: My ~/.bash_profile file:

# added by Anaconda 1.5.1 installer
export PATH="/Users/[my user name]/anaconda/bin:$PATH"

And my ~/.profile file:

# MacPorts Installer addition on 2013-03-12_at_12:06:00: 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.


##
# Your previous /Users/[my user name]/.profile file was backed up as /Users/[my user name]/.profile.macports-saved_2013-03-21_at_16:08:32
##

# MacPorts Installer addition on 2013-03-21_at_16:08:32: 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.


##
# Your previous /Users/[my user name]/.profile file was backed up as /Users/[my user name]/.profile.macports-saved_2013-03-21_at_16:14:16
##

# MacPorts Installer addition on 2013-03-21_at_16:14:16: 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.

I'm not sure where to add /opt/local/bin as suggested by Celada.

share|improve this question
    
"Running $PATH" makes no sense. $PATH contains a colon-separated list of directories. You can't treat that as a command and run it. –  Celada Jun 22 '13 at 19:34
    
What reasons can there be for bash's inability to access brew, macports, and a number of other applications? –  at least three characters Jun 22 '13 at 19:39
    
Well, as for Macports, I notice that /opt/local/bin is not in your $PATH which is probably should be. brew, I'm not familiar with. But if you changed your $PATH, you did it by some other means than simply defining a harmless alias (which doesn't even live longer than the shell it was defined in). Check if you changed ~/.profile or ~/.bash_profile or similar files, for example. –  Celada Jun 22 '13 at 19:44
    
I've found both ~/.profile and ~/.bash_profile, but they show conflicting values for $PATH. –  at least three characters Jun 22 '13 at 20:22
    
Well, I would say that setting $PATH in both ~/.profile and ~/.bash_profile is poor form, but the bash manpage mentions "~/.bash_profile, ~/.bash_login, and ~/.profile, in that order", so at least you know which one runs latest and therefore overrides changes made in the others. –  Celada Jun 22 '13 at 20:29
show 1 more comment

1 Answer

up vote 0 down vote accepted

The alias you present:

alias jhbuild="PATH=gtk-prefix/bin:$PATH jhbuild"

doesn't change the default $PATH. In fact, it doesn't even change the $PATH for the current shell. It changes the $PATH only for the run of the jhbuild command. Theres is no "restoring" that you should have to be doing. Even if you had changed the $PATH for the current shell, closing the shell in which you had done that would have sufficed to get rid of the change.

Based on the very odd error message you receive when trying to set the $PATH to something else, I suspect that the alias you defined earlier is somehow not the alias you thought you defined (a quoting problem?). I can't imagine what it might have been though. I can't imagine what would cause the error message when you are trying to reset the $PATH to mention aliases in any way at all.

I suggest you type alias alone without arguments to see what aliases are actually defined. That might give you a clue.

share|improve this answer
    
The only defined alias is alias jhbuild='PATH=gtk-prefix/bin:/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/us‌​r/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin jhbuild'. Is there any other reason why typing brew or port would return command not found by bash? –  at least three characters Jun 22 '13 at 19:21
    
The existence of that alias would have absolutely no effect on brew or port. –  Celada Jun 22 '13 at 19:28
    
I ran $PATH and posted the result in the main question. –  at least three characters Jun 22 '13 at 19:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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