2

Ruby and Rails has been running fine on my Mac, but I'm suddenly having some problems. When I try to run the server or generate a model (i.e. use the 'rails' command in anyway) I get this error

/Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:187:in `stub_source_index170': uninitialized constant Gem::SourceIndex (NameError)
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:353:in `stub_rubygems'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:250:in `replace_entrypoints'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:14:in `setup'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:116:in `setup'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/setup.rb:7:in `<top (required)>'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `require'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:35:in `require'
    from /Users/tm/Sites/anwaltythree/config/boot.rb:6:in `<top (required)>'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Users/tm/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
    from script/rails:5:in `<main>'

I randomly tried to run bundle update and got this error

Fetching gem metadata from https://rubygems.org/..

NoMethodError: private method `open' called for Gem::Package:Class
An error occurred while installing rake (10.0.4), and Bundler cannot continue.
Make sure that `gem install rake -v '10.0.4'` succeeds before bundling.

Following its instructions, I installed rake

gem install rake -v '10.0.4'
Successfully installed rake-10.0.4
Installing ri documentation for rake-10.0.4

However, I get the same errors with the 'rails' command and bundle update as described above.

The error is occurring across multiple project folders.

The only difference between today and yesterday (when everything worked fine) is that I installed jekyll last night and, while troubleshooting that, ran some 'sudo' commands, which I normally don't ever have to run. I have no idea whether that's related to the current problem. I'm just providing context.

I'm at a loss for what to do next. Can you suggest what I might try

4

2 回答 2

11

Its quite possible that the versioning of ruby/gem/bundler might have switched or changed. Couple of things you could do is

  1. Check what version of ruby you are on ruby -v.
  2. Then pass in rvm use 1.9.3 your terminal again.
  3. I remember reading Gem::Package no longer supports the open method. So try updating your gem system (gem update --system).
  4. You can then bundle your gem file again (its a good idea to update your bundle again, this could be the issue, so gem install bundler)
  5. Make sure to delete the .lock file before bundle.
于 2013-03-30T18:07:06.817 回答
2

I just ran

gem update bundler

Then all good to go.

于 2013-04-25T07:08:43.317 回答