Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm really new to Mac OSX and UNIX based systems. I wanted to run a few Windows games on my Mac Mini so I started installing Wine and MacPorts.

Having done so, I typed in sudo port install wine and the terminal returned a not found error. I tried other basic commands like say and clear and all of them return the not found error. I've googled this and all I've understood so far is that the PATH might be incorrectly set. So I ran this command: echo $PATH and it returned this:

/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin

Can anyone tell me how to set this path correctly? I'm a complete newbie to mac and have no idea where .bash_profile or any of those files are. If it helps, I've also installed Xcode and the Command Line tools for Xcode. I'm running Mountain Lion.

share|improve this question
1  
Unfortunately I think you need a tutorial on Unix as although we can answer the question we probably cannot provide enough background to help you understand it. As for Wine - easiest is try Crossover(costs) or Wineskin(free) which do not require terminal use –  Mark Feb 22 '13 at 11:27

2 Answers 2

up vote 5 down vote accepted

$PATH should contain these folders: /usr/bin:/usr/sbin:/bin:/sbin.

Try editing ~/.bash_profile, ~/.profile, or ~/.bash_login (with for example /usr/bin/open ~/.bash_profile -a TextEdit) and commenting out any lines that modify the path.

If that works, you can add a line like export PATH=/opt/local/bin:/opt/local/sbin:$PATH to ~/.bash_profile.

share|improve this answer
    
I tried export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin and it works but once I close and reopen the terminal, it goes back to the same error again. I'm a complete noob and I have no idea where ~/.bash_profile or any of those files are located. I'm assuming they're hidden? –  Jack Copeland Feb 22 '13 at 8:33
    
~/ is the home folder (/Users/username/). Files starting with a period are hidden, but you can show them with for example ls -la. –  ؘؘؘؘ Feb 22 '13 at 9:49

It sounds like you overwrote you path rather then just adding to it.

Make sure when you set your PATH you include "${PATH}" to include your existing path as well

By default the $PATH is set in a couple of files. Technically you should add to your $PATH in the .bash_profile file in you home directory.

One suggestion if to check if certain folder exist before you add them to your PATH.

For example I have:

if [ -d /usr/local/bin ] ; then
    PATH=/usr/local/bin:"${PATH}"
fi

if [ -d /usr/local/mysql/bin ] ; then
    PATH=/usr/local/mysql/bin:"${PATH}"
fi

if [ -d /opt/local/bin ] ; then
    PATH=/opt/local/bin:"${PATH}"
fi

if [ -d /opt/local/sbin ] ; then
    PATH=/opt/local/sbin:"${PATH}"
fi

if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi

( The -d directory command check to see if the directory exists )

share|improve this answer

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.