Brew: Problems installing (w/ Ruby 1.8/CentOS6/RHEL6)

Created on 25 Oct 2017  Â·  20Comments  Â·  Source: Linuxbrew/brew

  • [x] Confirmed this is a problem with running a brew command and not brew installing or the post-install behaviour of one or more formulae? If it's a formulae-specific problem please file this issue at the relevant tap e.g. for Linuxbrew/homebrew-core https://github.com/Linuxbrew/homebrew-core/issues/new
  • [x] Ran brew update and retried your prior step?
  • [ ] Ran brew doctor, fixed all issues and retried your prior step?
  • [x] Ran brew config and brew doctor and included their output with your issue?

Running on RHEL6 and CentOS6 (which I believe to be supported?); Get the error on or after installation:

/usr/bin/ruby: no such file to load -- rubygems (LoadError)
/home/brewser/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:83: syntax error, unexpected ':', expecting kEND
    Homebrew.help cmd, empty_argv: empty_argv
                                  ^
/home/brewser/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:125: syntax error, unexpected ':', expecting kEND
  Homebrew.help cmd, usage_error: e.message
                                 ^

This happens inconsistently; on my RH6 station it happens during install; on a CentOS6 docker image it happens after installation, but when running any of the brew commands (e.g. doctor, config)

The internet suggests this is a old ruby (1.8) problem. There's a test in the installer for missing ruby (and so a portable version is installed as "Homebrew ruby" first) but the only check is for existence - no version.

Manually downloading and removing the ruby test which ruby >/dev/null || from the install.sh forces the portable 2.x to be installed and appears to fix the problem.

Presumably there should be a test for ruby version in the installer?

bug stale

Most helpful comment

@ivan-krukov Try these installation instructions for CentOS6:
https://github.com/Linuxbrew/brew/wiki/CentOS6

All 20 comments

Here's what's supposed to happen. Reality may of course differ from intention.
The Linuxbrew installation script in Ruby should work just fine with any old version of Ruby. Your old version of Ruby is only used to boot-strap a newer version. That bootstrapping process is supposed to work with old versions of Ruby. That's why there's no check on Ruby version in the Linuxbrew installation script in Shell. From a clean installation, can you please report the entire log of running the command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

If/when that fails, please report the complete output of

brew vendor-install ruby

Here's the log of the failing installation:

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
==> Select the Linuxbrew installation directory
- Enter your password to install to /home/linuxbrew/.linuxbrew (recommended)
- Press Control-D to install to /home/mep23677/.linuxbrew
- Press Control-C to cancel installation
[sudo] password for mep23677: 
sudo: pam_authenticate: Conversation error
==> This script will install:
/home/mep23677/.linuxbrew/bin/brew
/home/mep23677/.linuxbrew/share/doc/homebrew
/home/mep23677/.linuxbrew/share/man/man1/brew.1
/home/mep23677/.linuxbrew/share/zsh/site-functions/_brew
/home/mep23677/.linuxbrew/etc/bash_completion.d/brew
/home/mep23677/.cache/Homebrew/
/home/mep23677/.linuxbrew/Homebrew
==> The following new directories will be created:
/home/mep23677/.linuxbrew/Cellar
/home/mep23677/.linuxbrew/bin
/home/mep23677/.linuxbrew/etc
/home/mep23677/.linuxbrew/include
/home/mep23677/.linuxbrew/lib
/home/mep23677/.linuxbrew/opt
/home/mep23677/.linuxbrew/sbin
/home/mep23677/.linuxbrew/share
/home/mep23677/.linuxbrew/share/zsh
/home/mep23677/.linuxbrew/share/zsh/site-functions
/home/mep23677/.linuxbrew/var
/home/mep23677/.linuxbrew/Homebrew

Press RETURN to continue or any other key to abort
==> /bin/mkdir -p /home/mep23677/.linuxbrew/Cellar /home/mep23677/.linuxbrew/bin /home/mep23677/.linuxbrew/etc /home/mep23677/.linuxbrew/include /home/mep23677/.linuxbrew/lib /home/mep23677/.linuxbrew/opt /home/mep23677/.linuxbrew/sbin /home/mep23677/.linuxbrew/share /home/mep23677/.linuxbrew/share/zsh /home/mep23677/.linuxbrew/share/zsh/site-functions /home/mep23677/.linuxbrew/var /home/mep23677/.linuxbrew/Homebrew
==> /bin/chmod g+rwx /home/mep23677/.linuxbrew/Cellar /home/mep23677/.linuxbrew/bin /home/mep23677/.linuxbrew/etc /home/mep23677/.linuxbrew/include /home/mep23677/.linuxbrew/lib /home/mep23677/.linuxbrew/opt /home/mep23677/.linuxbrew/sbin /home/mep23677/.linuxbrew/share /home/mep23677/.linuxbrew/share/zsh /home/mep23677/.linuxbrew/share/zsh/site-functions /home/mep23677/.linuxbrew/var /home/mep23677/.linuxbrew/Homebrew
==> /bin/chmod 755 /home/mep23677/.linuxbrew/share/zsh /home/mep23677/.linuxbrew/share/zsh/site-functions
==> /bin/chown mep23677 /home/mep23677/.linuxbrew/Cellar /home/mep23677/.linuxbrew/bin /home/mep23677/.linuxbrew/etc /home/mep23677/.linuxbrew/include /home/mep23677/.linuxbrew/lib /home/mep23677/.linuxbrew/opt /home/mep23677/.linuxbrew/sbin /home/mep23677/.linuxbrew/share /home/mep23677/.linuxbrew/share/zsh /home/mep23677/.linuxbrew/share/zsh/site-functions /home/mep23677/.linuxbrew/var /home/mep23677/.linuxbrew/Homebrew
==> /bin/chgrp mep23677 /home/mep23677/.linuxbrew/Cellar /home/mep23677/.linuxbrew/bin /home/mep23677/.linuxbrew/etc /home/mep23677/.linuxbrew/include /home/mep23677/.linuxbrew/lib /home/mep23677/.linuxbrew/opt /home/mep23677/.linuxbrew/sbin /home/mep23677/.linuxbrew/share /home/mep23677/.linuxbrew/share/zsh /home/mep23677/.linuxbrew/share/zsh/site-functions /home/mep23677/.linuxbrew/var /home/mep23677/.linuxbrew/Homebrew
==> Downloading and installing Linuxbrew...
remote: Counting objects: 6226, done.
remote: Compressing objects: 100% (3387/3387), done.
remote: Total 6226 (delta 3946), reused 4248 (delta 2673), pack-reused 0
Receiving objects: 100% (6226/6226), 2.70 MiB | 1.80 MiB/s, done.
Resolving deltas: 100% (3946/3946), done.
From https://github.com/Linuxbrew/brew
 * [new branch]      master     -> origin/master
 * [new tag]         1.0.0      -> 1.0.0
 * [new tag]         1.0.1      -> 1.0.1
 * [new tag]         1.0.2      -> 1.0.2
 * [new tag]         1.0.3      -> 1.0.3
 * [new tag]         1.0.4      -> 1.0.4
 * [new tag]         1.0.5      -> 1.0.5
 * [new tag]         1.0.6      -> 1.0.6
 * [new tag]         1.0.7      -> 1.0.7
 * [new tag]         1.0.8      -> 1.0.8
 * [new tag]         1.0.9      -> 1.0.9
 * [new tag]         1.1.0      -> 1.1.0
 * [new tag]         1.1.0.1    -> 1.1.0.1
 * [new tag]         1.1.1      -> 1.1.1
 * [new tag]         1.1.10     -> 1.1.10
 * [new tag]         1.1.11     -> 1.1.11
 * [new tag]         1.1.12     -> 1.1.12
 * [new tag]         1.1.13     -> 1.1.13
 * [new tag]         1.1.2      -> 1.1.2
 * [new tag]         1.1.2.1    -> 1.1.2.1
 * [new tag]         1.1.3      -> 1.1.3
 * [new tag]         1.1.4      -> 1.1.4
 * [new tag]         1.1.5      -> 1.1.5
 * [new tag]         1.1.6      -> 1.1.6
 * [new tag]         1.1.7      -> 1.1.7
 * [new tag]         1.1.8      -> 1.1.8
 * [new tag]         1.1.9      -> 1.1.9
 * [new tag]         1.2.0      -> 1.2.0
 * [new tag]         1.2.1      -> 1.2.1
 * [new tag]         1.2.2      -> 1.2.2
 * [new tag]         1.2.3      -> 1.2.3
 * [new tag]         1.2.4      -> 1.2.4
 * [new tag]         1.2.5      -> 1.2.5
 * [new tag]         1.2.6      -> 1.2.6
 * [new tag]         1.2.7      -> 1.2.7
 * [new tag]         1.2.8      -> 1.2.8
 * [new tag]         1.3.0      -> 1.3.0
 * [new tag]         1.3.1      -> 1.3.1
 * [new tag]         1.3.2      -> 1.3.2
 * [new tag]         1.3.3      -> 1.3.3
 * [new tag]         1.3.4      -> 1.3.4
 * [new tag]         1.3.5      -> 1.3.5
Checking out files: 100% (1128/1128), done.
HEAD is now at b39b60a Merge tag Homebrew/1.3.6 into Linuxbrew/master
/usr/bin/ruby: no such file to load -- rubygems (LoadError)
/dls/science/users/mep23677/brew/brew/Homebrew/Library/Homebrew/brew.rb:83: syntax error, unexpected ':', expecting kEND
    Homebrew.help cmd, empty_argv: empty_argv
                                  ^
/dls/science/users/mep23677/brew/brew/Homebrew/Library/Homebrew/brew.rb:125: syntax error, unexpected ':', expecting kEND
  Homebrew.help cmd, usage_error: e.message
                                 ^
Failed during: /home/mep23677/.linuxbrew/bin/brew update --force

brew vendor-install ruby actually seems to solve the problem:
```$ brew vendor-install ruby
==> Downloading https://homebrew.bintray.com/bottles-portable/portable-ruby-2.3.3.x86_64_linux.bottle.tar.gz
Already downloaded: /home/mep23677/.cache/Homebrew/portable-ruby-2.3.3.x86_64_linux.bottle.tar.gz
==> Pouring portable-ruby-2.3.3.x86_64_linux.bottle.tar.gz

So, it looks like if that's supposed to happen, then it isn't. I don't have sudo access on the system I'm trying to install, so that could be one difference from "normal"? I can somewhat reproduce the problem on a docker centos6 with:

from centos:centos6

RUN yum install -y ruby git curl file git python-setuptools
RUN useradd -m brewser

USER brewser
WORKDIR /home/brewser

Fails first time with 'private method `gsub' called for nil:NilClass (NoMethodError)' but

cannot reproduce on RH6; assuming is a docker problem

RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" ||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

ENV PATH="/home/brewser/.linuxbrew/bin:${PATH}"
RUN echo $PATH
RUN brew doctor
```

Although the install fails the first time, I'm assuming it's a docker issue because I don't have any other way to replace it.

Here's a Dockerfile for CentOS 6 that works: https://github.com/Linuxbrew/docker/blob/master/centos6/Dockerfile

# Fails first time with 'private method `gsub' called for nil:NilClass (NoMethodError)' but

That looks like a bug in Linuxbrew, but may not be high priority to fix. A PR is most welcome if you dig into it and find a fix.

The order of execution is supposed to be…

bin/brew
Library/Homebrew/brew.sh
Library/Homebrew/utils/ruby.sh
Library/Homebrew/cmd/vendor-install.sh

All that's shell code, so no Ruby (except for the installer script) is supposed to be executed until the new version of Ruby is boot strapped. It's clearly not working as intended in your case.

The work around for now is either…

eval "`curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install-ruby`"
ruby -e "`curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install`"

or

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
brew vendor-install ruby

I'll try to look into this further when I find time. If you dig into it deeper, a PR to fix this issue would be most welcome.

Second workaround (brew vendor-install ruby) works for me. (ruby 1.8.6, centos6)

Thanks for the centos fix; I imagined a normally configured systems wouldn't have that problem - and obviously it works fine when ruby is completely missing.

And vendor-install is a simple-enough workaround.

Relatedly to versioning but in the possibly-separate-bug category, it also doesn't seem to handle the system git==1.7.1 very well; When git is missing it properly bootstraps itself from bottles - but when the system git 1.7.1 is present:

  • Installation doesn't warn you
  • Anything that triggers an update fails (error: unknown option 'list' from git, then hangs)
  • brew doctor tells you to brew install git
  • brew install git causes a self-update, which obviously fails

You seem to need to HOMEBREW_NO_AUTO_UPDATE=1 brew install git to actually fix the problem, which isn't obvious unless you know homebrew. Perhaps the brew doctor git error should tell you to use no-update (or even special-case install git installs).

I've also had Error: glibc cannot be built with any available compilers. problems but haven't investigated/diagnosed that thoroughly yet (seems to not be the named-gcc-symlink error).

Following up on glibc cannot be built with any available compilers - same issue on my side. I am trying to sylink gcc4.4 as per instructions here - no luck yet.

@ivan-krukov Which distribution of Linux are you using?

I'm guessing that the git tag --list error comes from one of these two places:
https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/cmd/update.sh#L220
https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/cmd/update.sh#L447

It checks whether git is installed. It should also check that the version of git is new enough:
https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/cmd/update.sh#L386

A PR would be welcome if you'd like to submit a fix. It is Hacktoberfest after all!
https://hacktoberfest.digitalocean.com

@sjackman CentOS release 6.8 (Final)

@ivan-krukov Try these installation instructions for CentOS6:
https://github.com/Linuxbrew/brew/wiki/CentOS6

Ah, that looks like it's the fix, thanks - I had only found the -core documentation and legacy bugs -
searching for the actual error message.

@sjackman It seems to have done the trick. The only other thing was to install git through brew, then it is all smooth sailing.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

I'm running across a similar problem to the one described by @ndevenish above:

â‹®
* [new tag]         1.3.4      -> 1.3.4
* [new tag]         1.3.5      -> 1.3.5
Checking out files: 100% (1128/1128), done.
HEAD is now at b39b60a Merge tag Homebrew/1.3.6 into Linuxbrew/master
/usr/bin/ruby: no such file to load -- rubygems (LoadError)
/dls/science/users/mep23677/brew/brew/Homebrew/Library/Homebrew/brew.rb:83: syntax error, unexpected ':', expecting kEND
    Homebrew.help cmd, empty_argv: empty_argv
                                  ^
/dls/science/users/mep23677/brew/brew/Homebrew/Library/Homebrew/brew.rb:125: syntax error, unexpected ':', expecting kEND
  Homebrew.help cmd, usage_error: e.message
                                 ^
Failed during: /home/mep23677/.linuxbrew/bin/brew update --force

But in my case I don't get the extra output:

â‹®
 * [new tag]         1.5.0      -> 1.5.0
 * [new tag]         1.5.1      -> 1.5.1
HEAD is now at 34aa15b Merge tag Homebrew/1.5.1 into Linuxbrew/master
Error: Git must be installed and in your PATH!
Failed during: /home/waldyrious/.linuxbrew/bin/brew update --force

git is indeed installed, but as mentioned above, it is in the 1.7.x series:

$ git --version
git version 1.7.11.4

This comment mentions that the update script

checks whether git is installed. It should also check that the version of git is new enough:
/Library/Homebrew/cmd/update.sh@83db371#L386

(I updated the link to point to the correct historical version, otherwise the line number reference gets out of sync)

Is that line change something that's still desirable? I'm willing to test the change and submit a PR, but I'll need some pointers at what the change should look like.

The Ruby error might be fixed with export HOMEBREW_FORCE_VENDOR_RUBY=1 See https://github.com/Linuxbrew/brew/issues/570

Yes, a fix to check the version of git would be welcome. I believe it requires git 1.8, which has the git config --local option. You could if you like submit this PR upstream to Homebrew/brew, if you're able to test it on macOS.

The Ruby error might be fixed with

Just to make sure, is my issue also a Ruby error? I thought it was just the git version mismatch.

Yes, a fix to check the version of git would be welcome. I believe it requires git 1.8,

Would the final code look something like this?

if you're able to test it on macOS.

No access to macOS at the moment, but I might be able to test in the next few days.

These are both Ruby errors.

/usr/bin/ruby: no such file to load -- rubygems (LoadError)
/dls/science/users/mep23677/brew/brew/Homebrew/Library/Homebrew/brew.rb:83: syntax error, unexpected ':', expecting kEND

Yes, something like that. This code that checks that Ruby is a new enough version is probably your best model:
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/ruby.sh#L40

Thanks, I'll give this a try in the next few days.

Sorry, I ended up getting quite swamped with other stuff. I'll try to tackle this when I can find the time/energy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thedrow picture thedrow  Â·  6Comments

nnmrts picture nnmrts  Â·  5Comments

gttiankai picture gttiankai  Â·  5Comments

pokiz picture pokiz  Â·  6Comments

h3adache picture h3adache  Â·  6Comments