Homebrew-core: gem command broken for default ruby (2.3.1p112)

Created on 30 Sep 2016  ยท  20Comments  ยท  Source: Homebrew/homebrew-core

Install homebrew.

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /Users/z/Library/Caches/Homebrew
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /Users/z/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown z /Users/z/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 1088, done.
remote: Compressing objects: 100% (972/972), done.
remote: Total 1088 (delta 110), reused 559 (delta 81), pack-reused 0
Receiving objects: 100% (1088/1088), 1.05 MiB | 990.00 KiB/s, done.
Resolving deltas: 100% (110/110), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
HEAD is now at 41b2df8 Merge pull request #1177 from scpeters/man_exit_code
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3725, done.
remote: Compressing objects: 100% (3616/3616), done.
remote: Total 3725 (delta 11), reused 672 (delta 1), pack-reused 0
Receiving objects: 100% (3725/3725), 2.98 MiB | 1.10 MiB/s, done.
Resolving deltas: 100% (11/11), done.
Checking connectivity... done.
Tapped 3604 formulae (3,752 files, 9.2M)
Already up-to-date.
==> Installation successful!
==> Next steps
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics

Check if everything works.

$ brew doctor
Your system is ready to brew.

Check config.

$ brew config
HOMEBREW_VERSION: 1.0.5
ORIGIN: https://github.com/Homebrew/brew
HEAD: a5565d8fd600bc2883ed76ca8708d08588d1ef3f
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: e280e416e1af55ab021277fcfbbc6aff22557569
Core tap last commit: 33 minutes 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 ivybridge
Homebrew Ruby: 2.0.0-p648
Clang: 7.3 build 703
Git: 2.7.4 => /Library/Developer/CommandLineTools/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: N/A
macOS: 10.11.6-x86_64
Xcode: N/A
CLT: 7.3.1.0.1.1461711523
X11: N/A

Check available Ruby versions.

$ brew info ruby
ruby: stable 2.3.1 (bottled), devel 2.4.0-beta2, HEAD
Powerful, clean, object-oriented scripting language
https://www.ruby-lang.org/
/usr/local/Cellar/ruby/2.3.1_1 (1,261 files, 18.9M) *
  Poured from bottle on 2016-09-30 at 10:13:38
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ruby.rb
==> Dependencies
Build: pkg-config โœ˜
Required: libyaml โœ”, openssl โœ”
Recommended: readline โœ”
Optional: gdbm โœ˜, gmp โœ˜, libffi โœ˜
==> Options
--universal
    Build a universal binary
--with-doc
    Install documentation
--with-gdbm
    Build with gdbm support
--with-gmp
    Build with gmp support
--with-libffi
    Build with libffi support
--with-suffix
    Suffix commands with '23'
--with-tcltk
    Install with Tcl/Tk support
--without-readline
    Build without readline support
--devel
    Install development version 2.4.0-beta2
--HEAD
    Install HEAD version
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/ruby

Install default Ruby.

$ brew install ruby
==> Installing dependencies for ruby: readline, libyaml, openssl
==> Installing ruby dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-7.0.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.


Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
๐Ÿบ  /usr/local/Cellar/readline/7.0: 45 files, 2M
==> Installing ruby dependency: libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.7.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libyaml-0.1.7.el_capitan.bottle.tar.gz
๐Ÿบ  /usr/local/Cellar/libyaml/0.1.7: 8 files, 312.5K
==> Installing ruby dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
๐Ÿบ  /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing ruby
==> Downloading https://homebrew.bintray.com/bottles/ruby-2.3.1_1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ruby-2.3.1_1.el_capitan.bottle.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/ruby
==> Summary
๐Ÿบ  /usr/local/Cellar/ruby/2.3.1_1: 1,261 files, 18.9M

Check Ruby and RubyGems versions and locations.

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

$ gem -v
2.5.1

$ which ruby
/usr/local/bin/ruby

$ which gem
/usr/local/bin/gem

Try installing a gem or updating RubyGems.

$ gem install bundler
ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument

$ gem update --system
ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument

Most helpful comment

Looks like everything works fine if Ruby is built from source.

brew install ruby --build-from-source

All 20 comments

Try installing development version of Ruby.

$ brew install ruby --devel
Warning: ruby-2.3.1_1 already installed

Uninstall current Ruby.

$ brew uninstall ruby
Uninstalling /usr/local/Cellar/ruby/2.3.1_1... (1,261 files, 18.9M)

Install development version of Ruby.

$ brew install ruby --devel
==> Installing dependencies for ruby: xz, pkg-config
==> Installing ruby dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.2.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring xz-5.2.2.el_capitan.bottle.tar.gz
๐Ÿบ  /usr/local/Cellar/xz/5.2.2: 91 files, 1.4M
==> Installing ruby dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
๐Ÿบ  /usr/local/Cellar/pkg-config/0.29.1_2: 10 files, 627.4K
==> Installing ruby
==> Using the sandbox
==> Downloading https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0-preview2.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/ruby/2.4.0-beta2_1 --enable-shared --disable-silent-rules --with-sitedir=/usr/local/lib/ruby/site_
==> make
==> make install
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/ruby
==> Summary
๐Ÿบ  /usr/local/Cellar/ruby/2.4.0-beta2_1: 1,224 files, 18.7M, built in 2 minutes 53 seconds

Check Ruby and RubyGems versions and locations.

$ ruby -v
ruby 2.4.0preview2 (2016-09-09 trunk 56129) [x86_64-darwin15]

$ gem -v
2.6.6

$ which ruby
/usr/local/bin/ruby

$ which gem
/usr/local/bin/gem

Install bundler.

$ gem install bundler
Fetching: bundler-1.13.1.gem (100%)
Successfully installed bundler-1.13.1
1 gem installed

Check bundler location.

$ which bundler
$

Try using bundler.

$ bundle install
-bash: bundle: command not found

Looks like bundler is not configured correctly. :(

Looks like bundler is not configured correctly. :(

Or alternatively: it's not put in your $PATH.

What should I have there?

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Is there something I have to add to $PATH?

Try installing an older version of Ruby.

$ brew search ruby
chruby                      imessage-ruby               mruby                       ruby                        ruby-install              
chruby-fish                 jruby                       rbenv-bundler-ruby-version  ruby-build                
homebrew/completions/ruby-completion           homebrew/versions/ruby182                      homebrew/versions/ruby22                     
homebrew/emacs/inf-ruby                        homebrew/versions/ruby186                      Caskroom/cask/madruby                        
homebrew/emacs/ruby-tools                      homebrew/versions/ruby187                      Caskroom/cask/rubymine                       
homebrew/nginx/mruby-nginx-module              homebrew/versions/ruby192                      Caskroom/cask/rubymotion                     
homebrew/versions/imagemagick-ruby186          homebrew/versions/ruby193                      Caskroom/versions/rubymine-eap               
homebrew/versions/jruby1721                    homebrew/versions/ruby20                     
homebrew/versions/jruby9000                    homebrew/versions/ruby21            

Install Ruby 2.2

$ brew install homebrew/versions/ruby22
==> Tapping homebrew/versions
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-versions'...
remote: Counting objects: 224, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 224 (delta 17), reused 28 (delta 7), pack-reused 0
Receiving objects: 100% (224/224), 270.93 KiB | 0 bytes/s, done.
Resolving deltas: 100% (17/17), done.
Checking connectivity... done.
Tapped 216 formulae (244 files, 988.6K)
==> Installing ruby22 from homebrew/versions
==> Downloading https://homebrew.bintray.com/bottles-versions/ruby22-2.2.5.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ruby22-2.2.5.el_capitan.bottle.tar.gz
==> Caveats
By default, binaries installed by gem will be placed into:
  /usr/local/lib/ruby/gems/2.2.0/bin

You may want to add this to your PATH.

This formula is keg-only, which means it was not symlinked into /usr/local.

macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/ruby22/lib
    CPPFLAGS: -I/usr/local/opt/ruby22/include
    PKG_CONFIG_PATH: /usr/local/opt/ruby22/lib/pkgconfig

==> Summary
๐Ÿบ  /usr/local/Cellar/ruby22/2.2.5: 1,091 files, 17.9M

This version of ruby does not put ruby executable in /usr/local/bin.

$ ls /usr/local/bin/*ruby*
ls: /usr/local/bin/*ruby*: No such file or directory

It is in /usr/local/Cellar/ruby22/2.2.5/bin/

$ ls /usr/local/Cellar/ruby22/2.2.5/bin/
erb gem irb rake    rdoc    ri  ruby

I am confused. Why would Ruby 2.2 "cause all kinds of trouble" and 2.3 would not.

What I guess is the most confusing to me is that until recently I could just brew install ruby and homebrew would make sure all binaries are in correct places. I did not have to add anything to $PATH. I do not mind configuring my system, but I am not sure what I need to do.

Looks like ruby 2.4.0preview2 installs executables (including bundle) in /usr/local/Cellar/ruby/2.4.0-beta2_1/bin/bundle so adding that to $PATH should work.

We see the same error on a completely new/clean El Capitan virtual machine

  1. MacOS 10.11.6 installed
  2. Xcode 8.0 installed
  3. nothing else's changed/installed
  4. installing brew with the one liner from http://brew.sh/
  5. brew install ruby

No error anywhere, but after this gem install ANYTHING fails with the

ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument

error.

We do this VM setup every week on Friday, and it worked last week.

Looks like everything works fine if Ruby is built from source.

brew install ruby --build-from-source

I can confirm that I solved the same issue with building from source as @zeljkofilipin said!

I tried building from source after uninstalling (brew uninstall ruby and brew install ruby --build-from-source) to no avail. Same gem error as reported elsewhere on 10.11.6 with Xcode 8.0.

I am not sure if it is relevant, but in debugging this I have:

Same issue here. Is there a PR in the works?

Not yet. Feel free to beat us to it.

To confirm some above advice, this got me at least working for now:

gem uninstall -aIx
brew uninstall ruby
brew install ruby --build-from-source
$ which ruby
/usr/local/bin/ruby
$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
$ gem --version
2.5.1
$ bundle --version
Bundler version 1.13.1

Have opened a PR to reproduce and start working on this in https://github.com/Homebrew/homebrew-core/pull/5480. I've reproduced it locally in a 10.11 VM (it's specific to there).

Unfortunately uninstalling gem + ruby and building from source isn't working here. Curious what the difference is. Personally I am running zsh vanilla...

ENV.delete("SDKROOT") fixes this.

Where does one add this? Ty

On Oct 1, 2016, at 8:56 PM, ilovezfs [email protected] wrote:

ENV.delete("SDKROOT") fixes this.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/Homebrew/homebrew-core/issues/5413#issuecomment-250947041, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJk07MCOq57mf1F2y4ErM9LsJPBtwowks5qvwFBgaJpZM4KK2Uz.

Confirming fix. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghostbar picture ghostbar  ยท  4Comments

daviderestivo picture daviderestivo  ยท  4Comments

ghost picture ghost  ยท  3Comments

bantl23 picture bantl23  ยท  3Comments

tejasmanohar picture tejasmanohar  ยท  3Comments