36

I've spent the bulk of my Friday trying to get the latest version of Ruby installed on my new MacBook Air (w/ Mountain Lion installed).

I have all the latest versions of XCode and command line tools. But I can't seem to get Homebrew to work! Here's a screenshot of where I keep getting stuck (I'm a new user, so can't embed this image).

As you can see I used the following to instal Homebrew:

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go/install)"

While there was a "warning" it seemed as though the installation worked:

Warning: /usr/local/bin is not in your PATH.
==> Installation successful!

Despite that, when I try to run "brew doctor" I received the following:

-bash: brew: command not found

Again, I'm trying to install homebrew, so i can instal the latest version of ruby -- I'm looking to learn to code in ruby, but kind of screwed if I can even get a development environment running! :)

vvvvv
  • 25,404
  • 19
  • 49
  • 81
RossPW
  • 399
  • 2
  • 4
  • 8
  • 1
    I got this message running your line: Whoops, the Homebrew installer has moved! Please instead run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Also, please ask wherever you got this link from to update it to the above. Thanks! – Eduardo Wada Jun 12 '15 at 02:27
  • Operating Systems: Windows..I tried to install brew through $pip install brew it went well downloading and unpacking. But my next task after unpacking brew is to install openssl using brew like $brew install openssl And I got an error stating brew command not found is there any solution for this ? – Praneeth Jun 15 '15 at 18:57
  • 1
    Does this answer your question? [How to install Homebrew on OS X?](https://stackoverflow.com/questions/20381128/how-to-install-homebrew-on-os-x) – Ivan Jan 09 '21 at 07:51

7 Answers7

67

The warning is telling you what is wrong. The problem is that brew is kept in /usr/local/bin

So, you can try /usr/local/bin/brew doctor

To fix it permanently alter your bash profile (.bashrc or .profile in your home directory) and add the following line:

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

On Apple silicone it's

export PATH=/opt/homebrew/bin/:$PATH
Pim van der Heijden
  • 6,956
  • 4
  • 16
  • 21
Daniel Evans
  • 6,788
  • 1
  • 31
  • 39
  • It worked super cool if we have ruby installed ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go/install)" – minhas23 May 27 '14 at 06:19
  • Really helped :) – Dibish Nov 01 '19 at 04:50
  • 2
    Future readers. I did this (via a new .profile file in my ~ home directory). But I also ran "source ~/.profile" (from a different answer I also upvoted) to make the changes "go live" instantly. – granadaCoder Sep 04 '20 at 19:26
  • 3
    If you guys have macbook apple silicone, you should notice that path is different. You should use below path `export PATH=/opt/homebrew/bin/:$PATH` – ali srn Jan 06 '21 at 22:12
  • Had to put it in the file ~/.zshrc instead of ~/.profile in order for the command to be picked up (M1 Mac Mini here). – Truisms Hounds Mar 31 '21 at 13:33
18

Check XCode is installed or not.

gcc --version
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update

http://techsharehub.blogspot.com/2013/08/brew-command-not-found.html "click here for exact instruction updates"

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Viji
  • 2,629
  • 1
  • 18
  • 30
13
nano ~/.profile

add these lines:

export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

save the file:

Ctrl + X then Y then Enter

then render the changes:

source ~/.profile

Gary Frey
  • 415
  • 4
  • 9
3

This was just happening to me, but none of the suggestions above worked. I changed directories ("cd ~/tmp") and suddenly the command

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

worked for me. Prior to changing directories I had been in a directory that is a Git repository. Perhaps that was interfering with the ruby and Git commands in the Brew install script.

Carl Rossman
  • 383
  • 1
  • 4
  • 10
  • changing to my tmp directory helped me resolve my related issue - which is that I was getting a message saying "Homebrew is already installed" - but none of the "brew" commands were working.
    NOTE: the installer asked me to pass on the following message, so here it is everybody: ***"Whoops, the Homebrew installer has moved! Please instead run:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    Also, please ask wherever you got this link from to update it to the above. Thanks!"***
    – Sergi May 17 '15 at 18:48
2

You can run in terminal

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"

then install https://github.com/robbyrussell/oh-my-zsh.

When those complate run i.e pico editor pico .zshrc and past those lines:

export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

remember use brew doctor :)

enter image description here

Darex1991
  • 855
  • 1
  • 10
  • 24
  • This answer is now outdated. Throws error message: The Linuxbrew GitHub repository has moved to https://github.com/Linuxbrew/brew Please see http://linuxbrew.sh for instructions to install Linuxbrew. – Jayprakash Dubey May 17 '20 at 08:05
-1

try this

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/linuxbrew/go/install)"
Kyll
  • 7,036
  • 7
  • 41
  • 64
ashutosh kumar
  • 207
  • 3
  • 4
  • 3
    While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Kyll Apr 19 '16 at 17:29
-3

You can use this:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" 

to install homebrew.

rik.vanmechelen
  • 1,904
  • 17
  • 24
  • the link couldn't be found you can use ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" instead – tolgayilmaz Oct 03 '15 at 07:24