Ruby gems path issue (system vs brew)

1.8k Views Asked by At

I'm having an issue with homebrew looking to the system gems when the system gems aren't in the $PATH.

Here is my gem env to show that my gems are installed in my .rvm/gems directory:

    RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5
  - RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin14]
  - INSTALLATION DIRECTORY: /Users/scott/.rvm/gems/ruby-2.2.2
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/scott/.rvm/gems/ruby-2.2.2/bin
  - SPEC CACHE DIRECTORY: /Users/scott/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.2.2/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /Users/scott/.rvm/gems/ruby-2.2.2
     - /Users/scott/.rvm/gems/ruby-2.2.2@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
     - :benchmark => false
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com
  - SHELL PATH:
     - /Users/scott/.rvm/gems/ruby-2.2.2/bin
     - /Users/scott/.rvm/gems/ruby-2.2.2@global/bin
     - /Users/scott/.rvm/rubies/ruby-2.2.2/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin
     - /Users/scott/.rvm/bin
     - /Users/scott/.composer/vendor/bin
     - /usr/local/sbin

Now here is the error message I keep getting on various commands (this in particular was from brew services start httpd22):

Error: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin14.3.0/ports/libxml2/2.8.0... OK
Running 'compile' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-apple-darwin14.3.0/ports/libxml2/2.8.0/compile.log' to see what happened.
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete compile task (RuntimeError)
    from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir'
    from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute'
    from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:69:in `compile'
    from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:109:in `cook'
    from extconf.rb:101:in `block in <main>'
    from extconf.rb:119:in `call'
    from extconf.rb:119:in `block in <main>'
    from extconf.rb:109:in `tap'
    from extconf.rb:109:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.1/gem_make.out

See how it's looking to the system version of Ruby & Gems? I have XCode installed and up to date.

brew doctor yields no results and brew update is ready to brew.

I'm using OS 10.10.3. Anything I've left out, just ask.

EDIT

Here is my .zshrc $PATH export:

export PATH="$PATH:$HOME/.composer/vendor/bin"
export PATH="$PATH:/usr/local/sbin"
export PATH="$PATH:$HOME/.rvm/bin"

EDIT 2

$GEM_HOME

/Users/scott/.rvm/gems/ruby-2.2.2

$GEM_PATH

/Users/scott/.rvm/gems/ruby-2.2.2:/Users/scott/.rvm/gems/ruby-2.2.2@global

Thoughts?

2

There are 2 best solutions below

0
On BEST ANSWER

Found the answer, the system rubygems.rb was referencing the wrong version of Ruby. More details here: https://github.com/Homebrew/homebrew/issues/31220

1
On

looking at brew:

https://github.com/Homebrew/homebrew/blob/master/bin/brew

https://github.com/Homebrew/homebrew/blob/master/bin/brew#L22

so brew is upsetting the GEM_PATH and doing its own thing.