【问题标题】:rails cannot find gems even after bundle install即使在捆绑安装之后,rails 也找不到 gem
【发布时间】:2018-09-01 23:07:43
【问题描述】:

我目前正在尝试在执行bundle install 之后启动我的 Rails 服务器。但是,当我尝试执行rails s 时,会弹出此错误

Could not find gem 'byebug (= 9.0.6)' in any of the gem sources listed in your Gemfile. Run bundle install to install missing gems.

然后我运行bundle install,但弹出相同的错误。我也尝试在 gemfile 中删除 byebug ,但它只是给了我同样的错误,但使用了不同的 gem。我尝试使用 gem install byebug -v 9.0.6 单独安装 byebug,但同样的问题仍然存在。

这是我的宝石文件

source 'https://rubygems.org'

gem 'rails',        '5.1.6'
gem 'puma',         '3.9.1'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks',   '5.0.1'
gem 'jbuilder',     '2.7.0'

group :development, :test do
  gem 'sqlite3', '1.3.12'
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug',  '9.0.6', platform: :mri 
end

group :development do
  gem 'web-console',           '3.5.1'
  gem 'listen',                '3.1.5'
  gem 'spring',                '2.0.2'
  gem 'spring-watcher-listen', '2.0.1'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

【问题讨论】:

  • Gemfile.lock 文件中的byebug 是什么版本?您可能需要运行bundle update,然后运行bundle install
  • 我的 gemfile.lock 中有 byebug (9.0.6),我运行了 bundle update,然后运行了 bundle install,但仍然遇到了同样的问题

标签: ruby-on-rails ruby rubygems


【解决方案1】:

您应该使用 bundle exec rails s 在包的上下文中运行您的 Rails 服务器。

【讨论】:

  • 我使用该命令运行,但它给了我同样的错误:|
  • 如果您的 Gemfile 中只有 rails gem,也会出现同样的错误?
  • 它给了我一个新错误:/Users/usr/.gem/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in require' :无法加载“聆听”宝石。将 gem 'listen'` 添加到 Gemfile 的开发组(LoadError)
  • 好的,现在尝试像以前一样添加相同的宝石,但不要复制/粘贴它们。
  • puma 工作正常,但我在 Gemfile 中列出的任何 gem 源中都无法找到 gem 'uglifier3.2.0'。错误
【解决方案2】:

就我而言,.bundle/config 中有以下一行

BUNDLE_WITHOUT: "test:development"

删除该行并运行bundle install 后,一切正常。

【讨论】:

    猜你喜欢
    • 2016-01-11
    • 2013-09-02
    • 2015-06-20
    • 1970-01-01
    • 2017-10-26
    • 1970-01-01
    • 2021-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多