Last Updated: February 25, 2016
· an0nym0use

Problems installing gems - "invalid option -2"

So you're trying to install a ruby gem, and you're getting this strange error, might look something like:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/andy/.rubies/ruby-2.1.3/bin/ruby extconf.rb 
/Users/andy/.rubies/ruby-2.1.3/bin/ruby: invalid option -2  (-h will show valid options) (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /Users/andy/.gem/ruby/2.1.3/gems/bcrypt-3.1.7 for inspection.
Results logged to /Users/andy/.gem/ruby/2.1.3/extensions/x86_64-darwin-14/2.1.0-static/bcrypt-3.1.7/gem_make.out
An error occurred while installing bcrypt (3.1.7), and Bundler cannot continue.
Make sure that "gem install bcrypt -v '3.1.7'" succeeds before bundling.

Check your RUBYOPT - this can get set incorrectly.

➜ ~  echo $RUBYOPT       

Fix this by unsetting this environment variable.

➜ ~  unset RUBYOPT