1

I've been searching for an answer to this problem for a few weeks now, and while I've seen similar problems, none that I have found have been exactly like the error I'm experiencing. I've tried uninstalling and reinstalling Homebrew to no avail. I'm not the most experienced user in the world of bash scripting and the command line in general, so be gentle with me.

I'm running Mac OS X 10.10.1 Yosemite.

Anyway, whenever I try to run a brew command of any kind, I get the following error-

PJs-iMac:~ peterjohnjoseph$ brew doctor
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: bad interpreter: Too many levels of symbolic links
/usr/local/bin/brew: line 28: /usr/local/Library/brew.rb: Undefined error: 0

My usr/local/bin/brew script looks like this -

    #!/bin/sh

chdir () {
  cd "$@" >/dev/null
}

BREW_FILE_DIRECTORY=$(chdir "${0%/*}" && pwd -P)
export HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/${0##*/}"

BREW_SYMLINK=$(readlink "$0")
if [ -n "$BREW_SYMLINK" ]
then
    BREW_SYMLINK_DIRECTORY=$(dirname "$BREW_SYMLINK")
    BREW_FILE_DIRECTORY=$(chdir "$BREW_FILE_DIRECTORY" &&
                          chdir "$BREW_SYMLINK_DIRECTORY" && pwd -P)
fi

BREW_LIBRARY_DIRECTORY=$(chdir "$BREW_FILE_DIRECTORY"/../Library && pwd -P)

# Users may have these set, pointing the system Ruby
# at non-system gem paths
unset GEM_HOME
unset GEM_PATH

BREW_SYSTEM=$(uname -s | tr "[:upper:]" "[:lower:]")
if [ "$BREW_SYSTEM" = "darwin" ]
then
    exec "$BREW_LIBRARY_DIRECTORY/brew.rb" "$@"
else
    exec ruby -W0 "$BREW_LIBRARY_DIRECTORY/brew.rb" "$@"
fi

The other thing is, I'm finding something that doesn't seem right to me (but I could be wrong) in the /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby folders.

First off, when clicking on ruby.framework/Versions the contents are an alias for 1.8 (is this supposed to be there if 2.0 is the default installed with os x 10.10? The alias also says it can't find the original item), a 2.0 folder, and a "Current' alias that when clicked on says the original item can not be found also. Inside the 2.0 folder, the "Current" alias there also can't find the original item.

Is any of this off, and could it have anything to do with why I'm getting the Homebrew error? This could be extremely simple and I just have to delete a line from a file, or it could be larger and involve the potential problems I found above. Any help would be greatly appreciated. I have some things I need to install this week, so I'm trying everything I can to figure and solve this. I'll give you any information you need in order to assist you in helping me.

Thanks, P.J.

Edit: 1/9/15 at 1:29 in response to David X-

Thanks David, I'd be happy to post the results. Thank you for trying anything at all. -

PJs-iMac:~ peterjohnjoseph$ ls -l /usr/local/Library/brew.rb
-rwxr-xr-x  1 peterjohnjoseph  admin  5284 Jan  9 10:06 /usr/local/Library/brew.rb

PJs-iMac:~ peterjohnjoseph$ ls -l /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
ls: /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: Too many levels of symbolic links

PJs-iMac:~ peterjohnjoseph$ head -1 /usr/local/Library/brew.rb
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0

PJs-iMac:~ peterjohnjoseph$ ls -ld /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
ls: /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: Too many levels of symbolic links

PJs-iMac:~ peterjohnjoseph$ ls -l /System/Library/Frameworks/Ruby.framework/Versions/
total 16
lrwxr-xr-x  1 root  wheel    7 Dec 30 08:44 1.8 -> Current
drwxr-xr-x  8 root  wheel  272 Dec 30 08:46 2.0
lrwxr-xr-x  1 root  wheel    3 Dec 25 01:21 Current -> 1.8

I'm assuming this means that Ruby.framework/Versions/Current/usr/bin/ruby is what is causing this. I don't know if this is anything you, or anyone else can work with, but like I said, anything at all is appreciated.

I don't know if this helps, but like I was saying earlier, the /System/Library/Frameworks/Ruby.framework/Versions/ folder only contains 3 items; an alias to 1.8 (that claims the original can not be found), a folder for 2.0, and an alias for "Current" (which also says the original can not be found when trying to Show Original).

Thanks again.

  • "I opened the usr/local/bin/brew file" No, you executed it, and got the same error you got (presumably) any other time you executed it. You need to use cat /usr/local/bin/brew to view it contents (assuming it's actually a script). – David X Jan 9 '15 at 17:52
  • I told you I was new.. I'm updating my post to include the contents of it. – Peter John Joseph Jan 9 '15 at 17:57
  • fair enough, I'm not familiar with OSX or brew, but good luck. – David X Jan 9 '15 at 18:00
  • Actually, can also post the results of ls -l /usr/local/Library/brew.rb /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby and head -1 /usr/local/Library/brew.rb? – David X Jan 9 '15 at 18:16
  • Sure can. Edited now. Like I said in the post, thank you so much for even trying. – Peter John Joseph Jan 9 '15 at 18:39
0

['Official' answer to summarize some debugging in the question comments]

It turned out to be that /System/Library/Frameworks/Ruby.framework/Versions/Current, which should have been a symlink to the latest version (2.0), was a symlink to 1.8 instead, which for some reason was itself a symlink back to Current, causing a infinite loop trying to resolve the symlink rather then a more useful "1.8 is missing or broken" error.

Solution was to fix Current to point to 2.0 again:

$ cd /System/Library/Frameworks/Ruby.framework/Versions/
$ ln -sfT 2.0 Current

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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