Brew: Brew cannot find /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Created on 21 Sep 2016  路  16Comments  路  Source: Homebrew/brew

When I type any brew command I get this output.

> brew /usr/local/bin/brew: /usr/local/Homebrew/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory /usr/local/bin/brew: line 21: /usr/local/Homebrew/Library/brew.rb: Undefined error: 0

A couple days ago, I had an update to Xcode 8. Afterward, I saw that I had the update bug (took me a while to notice it) and was able to fix it with the procedure given on the main page.

Before that I had my homebrew and brews up-to-date. Could any of these changes caused the bug?

Most helpful comment

If that fails try cd /usr/local Homebrew; git fetch origin; git reset --hard origin/master.

All 16 comments

Looks like you've ended up in an older version of Homebrew. Can you try this:

cd /usr/local/Homebrew
git fetch origin
git checkout 1.0.1

If that fails try cd /usr/local Homebrew; git fetch origin; git reset --hard origin/master.

@mistydemeo solution worked until I did a 'brew upgrade', then the error came back. Once I did @MikeMcQuaid command it fixed everything and it seems to stick. Thanks for the help.

Here are the results of the first test, with the 'git checjout 1.0.1' if you are interested:

> git checkout 1.0.1
Checking out files: 100% (3796/3796), done.
Note: checking out '1.0.1'. 

...detached HEAD warning by git...

> brew --version
Homebrew 1.0.0 (git revision a381b; last commit 2016-09-21)
Homebrew/homebrew-core (git revision 1938; last commit 2016-09-21)

> brew upgrade
Checking out vpr-24686 in /usr/local/Homebrew...
To checkout  in /usr/local/Homebrew run:
  'cd /usr/local/Homebrew && git checkout
/usr/local/bin/brew: /usr/local/Homebrew/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Homebrew/Library/brew.rb: Undefined error: 0
/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: No such file or directory -- /usr/local/Homebrew/Library/Homebrew/brew.rb (LoadError)

> brew
/usr/local/bin/brew: /usr/local/Homebrew/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Homebrew/Library/brew.rb: Undefined error: 0

Glad to hear it's working ok!

This reappears to me after every brew update.

$ brew update
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
/usr/local/bin/brew: /usr/local/Homebrew/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Homebrew/Library/brew.rb: Undefined error: 0

@synthmeat Can we see your brew config from when it's working? Thanks!

Of course.

$ brew config
HOMEBREW_VERSION: 1.0.2-45-g9001855-dirty
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 9001855d64c4f069a0983cf0b82815766fd9c035
Last commit: 32 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 966383f9e13e03c53290f38bea3a94f6fa4bddc6
Core tap last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.0.0-p648
GCC-4.2: build 5666
Clang: 8.0 build 800
Git: 2.10.0 => /usr/local/bin/git
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.24.0_1/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.3.1/bin/ruby
Java: 1.8.0_45, 1.8.0_25
macOS: 10.12-x86_64
Xcode: 8.0
CLT: N/A
X11: 2.7.9 => /opt/X11

And after you run brew update what does GIT_DIR=/usr/local/Homebrew git show say and GIT_DIR=/usr/local/Homebrew git tag --list --sort=-version:refname? Thanks!

12:16 synthmeat@zrak /Users/synthmeat 
$ GIT_DIR=/usr/local/Homebrew git show
fatal: Not a git repository: '/usr/local/Homebrew'
12:16 synthmeat@zrak /Users/synthmeat 
$ GIT_DIR=/usr/local/Homebrew git tag --list --sort=-version:refname
fatal: Not a git repository: '/usr/local/Homebrew'

Whoops, sorry, forgot my Git syntax:

GIT_DIR=/usr/local/Homebrew/.git git show say and GIT_DIR=/usr/local/Homebrew/.git git tag --list --sort=-version:refname after running brew update and seeing that same error message. Thanks!

12:19 synthmeat@zrak /usr/local/Homebrew [vpr-24686]
$ GIT_DIR=/usr/local/Homebrew/.git git show
commit a74577d5a6ef480240cb2cb2055c8cc8ce301828
Author: BrewTestBot <[email protected]>
Date:   Wed Nov 27 08:53:02 2013 +0000

    git: update 1.8.4.3 bottle.

diff --git a/Library/Formula/git.rb b/Library/Formula/git.rb
index b6455ec..f02b53e 100644
--- a/Library/Formula/git.rb
+++ b/Library/Formula/git.rb
@@ -7,9 +7,10 @@ class Git < Formula
   head 'https://github.com/git/git.git'

   bottle do
-    sha1 'ff5dc5105e0a56bf016139ae0c6dda12f4234c32' => :mavericks
-    sha1 'd2c663ea9922ab16b5e789e461aa62d2e0cb1072' => :mountain_lion
-    sha1 'd88e30d0f7fe799c4baf62aef544b3c5d96be9e6' => :lion
+    revision 1
+    sha1 'b30e3fbe6b8e4e3307c96b5924378ad302deb5ab' => :mavericks
+    sha1 '17d2cde9690251789672218a52113cfa8a702560' => :mountain_lion
+    sha1 'b5a0da40e046f706dc303cc853b8466e81e081ba' => :lion
   end

   option 'with-blk-sha1', 'Compile with the block-optimized SHA1 implementation'
12:19 synthmeat@zrak /usr/local/Homebrew [vpr-24686]
$ GIT_DIR=/usr/local/Homebrew/.git git tag --list --sort=-version:refname
pr-24686
pr-24201
1.0.2
1.0.1
1.0.0
0.9.9
0.9.8
0.9.5
0.9.4
0.9.3
0.9.2
0.9.1
0.9
0.8.1
0.8
0.7.1
0.7
0.6
0.5
0.4
0.3
0.2
0.1

Huh, fun. Thanks for helping us find a weird edge-case! The workaround for you is to GIT_DIR=/usr/local/Homebrew/.git git tag -d pr-24686 pr-24201 and then rerun brew update.

No, still the same error.

12:19 synthmeat@zrak /usr/local/Homebrew [vpr-24686]
$ GIT_DIR=/usr/local/Homebrew/.git git tag -d pr-24686 pr-24201
Deleted tag 'pr-24686' (was de96974)
Deleted tag 'pr-24201' (was a2f37ea)
12:23 synthmeat@zrak /usr/local/Homebrew [vpr-24686]
$ brew update
/usr/local/bin/brew: /usr/local/Homebrew/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Homebrew/Library/brew.rb: Undefined error: 0

Sorry, you'll need to git reset --hard once more, then brew update and things should still be 馃啑.

Yes, after git reset --hard origin/master everything appears to be in order.

Thank you!

Great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vitahlin picture vitahlin  路  4Comments

fooness picture fooness  路  4Comments

hktalent picture hktalent  路  4Comments

VagelisD picture VagelisD  路  3Comments

DomT4 picture DomT4  路  3Comments