gem install fails for any gem (e.g. bundler, cocoapods).
$ gem install bundler
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument
Background
On a new macbook (Mid 2015) running OSX El Capitan v10.11.6 (15G31), I started setting it up for development work and installed xcode8, brew & ruby. My gem env
:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /usr/local/bin
- USER INSTALLATION DIRECTORY: /Users/__username__/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin/bin
- SPEC CACHE DIRECTORY: /Users/__username__/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.3.1_1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /usr/local/bin
- /Users/__username__/.gem/ruby/2.3.0
- /usr/local/lib/ruby/gems/2.3.0
- /usr/local/Cellar/ruby/2.3.1_1/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "-n/usr/local/bin"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Library/Frameworks/Python.framework/Versions/3.4/bin
- /Library/Frameworks/Python.framework/Versions/3.4/bin
Some of existing posts:
Many of the existing posts are focused on another similar error you get that is related to "rootless" security feature in El Capitan:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted
Some of Errno::EPERM related posts: 1: CocoaPods issue 3680, 2: Stackoverflow Windows7, 3: Bundler issue 4065
What didn't work:
gem install
variants
$ sudo gem install bundler -n /usr/local/bin -V
Setting $GEM_HOME to /usr/local/bin and ~/.gems.
echo $GEM_HOME
/usr/local/bin
echo $GEM_HOME
~/.gems
"rootless" disable
sudo nvram boot-args="rootless=0"; sudo reboot