I recently updated my Mac Mini to OS 10.8 Mountain Lion, and using Ruby gems with RVM 1.16.8, Ruby 1.9.3p194 no longer works.
Here is the concise version of the error:
`load_api_keys': undefined method `key?' for #<String:0x007f865a928a28> (NoMethodError)
When I run any command like gem install bundler or gem -v I get the error below:
➜ ~ gem
/Users/brettchalupa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:227:in `load_api_keys': undefined method `key?' for #<String:0x007f865a928a28> (NoMethodError)
from /Users/brettchalupa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:208:in `initialize'
from /Users/brettchalupa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `new'
from /Users/brettchalupa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `do_configuration'
from /Users/brettchalupa/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:51:in `run'
from /Users/brettchalupa/.rvm/rubies/ruby-1.9.3-p194/bin/gem:25:in `<main>'
➜ ~ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]
➜ ~ rvm -v
rvm 1.16.8 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
I have gone in and commented out the conflicting method call load_api_keys which makes things function properly, but it then breaks any interaction with rubygems.org.
The issue is line :227, if @api_keys.key? :rubygems_api_key then
def load_api_keys
@api_keys = if File.exist? credentials_path then
load_file(credentials_path)
else
@hash
end
if @api_keys.key? :rubygems_api_key then
@rubygems_api_key = @api_keys[:rubygems_api_key]
@api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems
end
end
After removing RVM and attempting to install different Rubies, I have not found a solution to this issue. I do not want to simply comment out something that removes functionality that I use.
If anyone could give any insight as to what is causing this and how to fix it, it would be much appreciated.
Remove (or move) /Users/brettchalupa/.gem/credentials and let it use the default credentials.