1
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 – 2015-01-09T17:52:02.537I told you I was new.. I'm updating my post to include the contents of it. – Peter John Joseph – 2015-01-09T17:57:33.913
fair enough, I'm not familiar with OSX or brew, but good luck. – David X – 2015-01-09T18:00:28.527
Actually, can also post the results of
ls -l /usr/local/Library/brew.rb /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
andhead -1 /usr/local/Library/brew.rb
? – David X – 2015-01-09T18:16:12.317Sure can. Edited now. Like I said in the post, thank you so much for even trying. – Peter John Joseph – 2015-01-09T18:39:55.480
Okay, how about
ls -ld /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
? (Sorry about not asking for that in the first place.) – David X – 2015-01-09T18:45:40.407It looks like the bad symlink is
Current
rather thanruby
, which explains why ls is complaining even with -d. Can you tryls -l /System/Library/Frameworks/Ruby.framework/Versions/
? – David X – 2015-01-09T19:18:04.903Updated it. You don't have to apologize for anything, the fact that you're doing anything to try and solve this is enough. I posted the results. Now, I'm obviously not an expert here, but is that file trying to tell me that my Current version is 1.8? If thats so, I don't see how it could be possible. My computer is fairly new, and ships with Ruby 2.0. If it is the case, something else must of tried to install it, and if thats so, I have no idea where to start. – Peter John Joseph – 2015-01-09T20:01:43.347
Yes, it seems to be bogus install of 1.8. You should be able to get the system working again with
cd /System/Library/Frameworks/Ruby.framework/Versions/ ; ln -sfT 2.0 Current
. (Edit: you might needsudo
on theln
.) – David X – 2015-01-09T20:43:09.730I honestly can't thank you enough. That solved the problem. Is there any way to give you credit? As far as I know you can't mark or vote comments, but I wasn't sure if there was another way. – Peter John Joseph – 2015-01-09T21:11:20.763
Sure, I'll add a answer. – David X – 2015-01-09T21:15:07.663