# Screwed up Terminal (and/or XCode) in attempt to setup Dev Environment



## Nkunkel (Jun 3, 2012)

So I'm trying to set up a developer environment for Ruby on Rails on my Macbook Pro running Lion 10.7.3.

Following this guide: How to install Xcode, Homebrew, Git, RVM, & Ruby 1.9.3 on Snow Leopard & Lion - Moncef Belyamani

I went to the Mac Store and installed XCode, as the Command Line Tools. I installed gcc and homebrew through the command prompt as instructed, however this is where I started running into problems. 

When I ran brew doctor to check if my system was "raring to brew" i got this output:




```
Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path. Please note that there is no correct
path at this time if you have *only* installed the Command Line Tools for Xcode.
If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of
these is (probably) what you want:

    sudo xcode-select -switch /Developer
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

DO NOT SET / OR EVERYTHING BREAKS!
```
Beeing a fool, I selected the first option and submitted 


```
sudo xcode-select -switch /Developer
```
and moments later realized the tutorial said to submit the second option 
Code:

```
sudo xcode-select -switch/Applications/Xcode.app/Contents/Developer
```
Now, no matter what I enter into the terminal I always get the following:

-bash: (whatever command I called) : command not found

There's a couple things I can do like switching directories and stuff, but anything sudo forget it.

So for example if I call up "brew doctor" on terminal it will say that my Xcode is configured with an invalid path and try to resubmit the second code: "sudo xcode-select -switch/Applications/Xcode.app/Contents/Developer" it still says "-bash: sudo: command not found"

Also this may be helpful in diagnosing the problem as I suspect it's where things went wrong. 


```
Niklas-Kunkels-MacBook-Pro:~ Niklas$ echo $PATH
/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/local/sbin:~/bin/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
```

I've been told to delete a bunch of plist files that bash loads whenever you open a new terminal session, however am having trouble finding them.


----------



## artov (Jun 4, 2012)

It seems you are missing /usr/bin from your PATH:



Nkunkel said:


> ```
> Niklas-Kunkels-MacBook-Pro:~ Niklas$ echo $PATH
> /usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/local/sbin:~/bin/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
> ```



Since sudo is "/usr/bin/sudo"; I guess it is no good.


----------



## BjarneDM (Jun 4, 2012)

Your ${PATH} value looks seriously messed up, and it seems as if *HomeBrew* is the culprit, as the _PATH-values_ used by *HomeBrew* has been inserted twice - and incorrectly one of the times as there's a missing *':'* in the definition of your ${PATH} 

So let's us start by fixing that your ${PATH}. I'ld like to see the output from this command :

```
/bin/ls -l /private/etc/paths*
```
Depending on the result of that, I'll be able to advise you further in what to do to fix this.


----------



## Nkunkel (Jun 4, 2012)

Here's the input/output


```
Niklas-Kunkels-MacBook-Pro:~ Niklas$ /bin/ls -l /private/etc/paths*
-rw-r--r--  1 root  wheel  45 Nov 16  2011 /private/etc/paths

/private/etc/paths.d:
total 0
-rw-r--r--  1 root  wheel  13 Nov 16  2011 50-X11
```

EDIT: also I should note, I went to the apple store and while they couldn't fix it, we did however discover that creating a new account with admin privileges has the terminal back to normal.


----------



## BjarneDM (Jun 12, 2012)

sorry, I've been busy with other stuff for a while, so didn't have time to return to you before now

now, the result from the command looks like it should, so I don't think the problem is there. But just to be certain, let's check what you've got. You ought to get the following :

```
pro17:~ root# /bin/cat /private/etc/paths.orig 
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
pro17:~ root# /bin/cat /private/etc/paths.d/50-X11 
/usr/X11/bin
```
now, the fact that a new account doesn't have the problem mentioned, indicates to me that the local files that Terminal reads has been corrupted. Unfortunately, there's a plethora of these  So let's take a look at the possible culprits and see what's in them :

```
/bin/cat  ~/.bashrc
/bin/cat  ~/.bash_profile
/bin/cat  ~/.bash_login
/bin/cat  ~/.profile
```
It's very possible you've only got one or two of these, so don't worry if you don't have all of them.


----------

