Ruby和Rails在我的Mac上运行良好,但我突然遇到了一些问题。当我尝试运行服务器或生成模型时(即无论如何都使用'rails'命令)我收到此错误
/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>'
我随机尝试运行捆绑更新并收到此错误
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.
按照说明,我安装了rake
gem install rake -v '10.0.4'
Successfully installed rake-10.0.4
Installing ri documentation for rake-10.0.4
但是,如上所述,我使用'rails'命令和bundle update获得了相同的错误。
多个项目文件夹中发生错误。
今天和昨天之间的唯一区别(当一切正常时)是我昨晚安装了jekyll,并且在进行故障排除时,运行了一些“sudo”命令,我通常不需要运行它们。我不知道这是否与当前的问题有关。我只是提供上下文。
我不知道接下来要做什么。你能说一下我的尝试吗
答案 0 :(得分:11)
很可能Rubyy / gem / bundler的版本控制可能已经切换或更改。你可以做的几件事是
ruby -v
上的红宝石版本。rvm use 1.9.3
您的终端。gem update --system
)。gem install bundler
)答案 1 :(得分:2)
我跑了
gem update bundler
然后一切顺利。