Trouble installing homebrew (broken ruby)?


(Andy Wright) #1

Hey,

I am setting up a new Mac (10.13.6) and when running the one line install script I get the following output:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubygems/core_ext/kernel_warn (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Site/2.3.0/rubygems.rb:1395:in `<top (required)>'
    from <internal:gem_prelude>:4:in `require'
    from <internal:gem_prelude>:4:in `<internal:gem_prelude>'
zsh: exit 1     /usr/bin/ruby -e

I seem to be at a bit of an impasse as I cannot install a new ruby without homebrew (RVM seems to need homebrew) and I, seemingly, cannot install homebrew without a better version of ruby.

In my attempts to workaround this I might have made things worse by following the manual install instructions. This seemed to suggest that I should install homebrew into /usr/local/homebrew and now I get errors about zsh completions (I use zsh).

Please help :s


(Sean Molenaar) #2

Can you try running the installer in bash?


(Andy Wright) #3

Of course :slight_smile:

I get basically the same output:

bash-3.2$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubygems/core_ext/kernel_warn (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Site/2.3.0/rubygems.rb:1395:in `<top (required)>'
    from <internal:gem_prelude>:4:in `require'
    from <internal:gem_prelude>:4:in `<internal:gem_prelude>'

(Mike McQuaid) #4

What does /usr/bin/ruby -e "puts fish" output?


(Andy Wright) #5

@MikeMcQuaid I get the following:

/usr/bin/ruby -e "puts fish"                                                                                                        1 ↵  121  12:46:06
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubygems/core_ext/kernel_warn (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Site/2.3.0/rubygems.rb:1395:in `<top (required)>'
    from <internal:gem_prelude>:4:in `require'
    from <internal:gem_prelude>:4:in `<internal:gem_prelude>'
zsh: exit 1     /usr/bin/ruby -e "puts fish"

@MikeMcQuaid & @SMillerDev thank you so, so much for helping :slight_smile:


(Claudia) #6

@atwright147 What happens when you run gem update --system (source of this suggestion), then try /usr/bin/ruby -e "puts fish" again?


(Andy Wright) #7

I had already done that before the …“puts fish” command I previously posted (sorry, should probably have mentioned that)


(Andy Wright) #8

Not sure if it is important but I have to use sudo to do that

sudo gem update --system
Password:
Latest version already installed. Done.

Interestingly, if I don’t use sudo I get the same error as I have previously posted:

gem update --system                                                                                                                 1 ↵  122  12:47:41
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubygems/core_ext/kernel_warn (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Site/2.3.0/rubygems.rb:1395:in `<top (required)>'
    from <internal:gem_prelude>:4:in `require'
    from <internal:gem_prelude>:4:in `<internal:gem_prelude>'

(Andy Wright) #9

I am also getting the following output when I open my terminal:

compinit:498: no such file or directory: /usr/local/share/zsh/site-functions/_brew
compinit:498: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask
compinit:shift:500: shift count must be <= $#

Probably due to my earlier attempt at a manual install


(Mike McQuaid) #10

Your system Ruby seems pretty badly broken. I’m bowing out here I’m afraid as this is not a Homebrew issue.


(Andy Wright) #11

Would you help me remove those */site-functions file references (I cannot see where they were added) and let me know which folders I need to remove from/usr/local to get me back to the start before bowing out please?


(Claudia) #12

@atwright147 I second what Mike suspects (i. e., hosed Ruby installation) but I’m kinda not ready to give up yet. Can you please post the output of sudo /usr/bin/gem update --debug --verbose --system?


(Andy Wright) #13

:slight_smile:

I get:

sudo /usr/bin/gem update --debug --verbose --system                                  ✔  137  15:24:15
NOTE:  Debugging mode prints all exceptions even when rescued
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/resolv.rb:171 - LoadError
Exception `Errno::ENOENT' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:296 - No such file or directory @ rb_file_s_stat - /Users/c55953a/.gem/specs/rubygems.org%443/specs.4.8
GET https://rubygems.org/specs.4.8.gz
200 OK
Latest version already installed. Done.

(Shaun Jackman) #14

One option is to use Brew’s portable-ruby to install Homebrew, as Linuxbrew does. For inspiration, see the install script at:



(Claudia) #15

Thanks @atwright147 for the additional info.

Let’s try and reset your Rubygems installation to the system default (the one that comes with macOS).
If you don’t mind losing your installed Gems, please run the following two command lines:

$ sudo rm -f '/usr/local/bin/update_rubygems'
$ sudo rm -rf '/Library/Ruby/Site/2.3.0'

Confirm that your Rubygems version is now back at 2.x:

$ /usr/bin/gem --version 2>/dev/null
2.5.2.3

What happens if you try installing Homebrew after that?


(Andy Wright) #16

@claui
I do apologise, I hadn’t seen your message.

I decided to assume that Ruby really was broken, as you had said. I have sent the laptop back to our IT dept to get it re-imaged. Hopefully that will fix this :slight_smile:

I will let you know how I get on.


@sjackman: Thank you for that, I did not know that that was a thing – I will bear it in mind for the future.


(Claudia) #17

@atwright147 No worries! Let us know
if Homebrew gives you any issues after re-imaging.


(Andy Wright) #18

It must have been a broken ruby install. After getting the Mac reinstalled, it all works now :slight_smile:

If anyone else comes across this thread and tries to troubleshoot using the step above, please note that /usr/bin/ruby -e "puts fish" should probably be /usr/bin/ruby -e "puts 'fish'" (notice the single quotes around fish). Without that change you would get another error (though that would be about the variable fish not being found).


TL;DR for this whole thread:

If you get an error similar to:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubygems/core_ext/kernel_warn (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Site/2.3.0/rubygems.rb:1395:in `<top (required)>'
    from <internal:gem_prelude>:4:in `require'
    from <internal:gem_prelude>:4:in `<internal:gem_prelude>'
zsh: exit 1     /usr/bin/ruby -e

You installation of system ruby is probably broken in some way. The quick solution is to re-install macOS


(Claudia) #19

@atwright147 As stated before, a slightly quicker fix would be to run:

sudo rm -f '/usr/local/bin/update_rubygems'

and:

sudo rm -rf '/Library/Ruby/Site/2.3.0'

(Crypt0 Graphic) #20

This worked for me. I installed Homebrew at last. Really i’ve read about too much but none of them worked. Thank you very mush.