【问题标题】:Rails console can't find Rake, but Bundler installed itRails 控制台找不到 Rake,但 Bundler 安装了它
【发布时间】:2018-04-06 02:55:05
【问题描述】:

Rake 12.3.1 在 Gemfile 中,并已安装:

/app # bundle install | grep rake
Using rake 12.3.1

/app # grep rake Gemfile.lock
      rake (>= 0.8.7)
    rake (12.3.1)

/app # bundle exec gem list | grep rake
rake (12.3.1)

Bundler 认为一切都很好:

/app # bundle check
The Gemfile's dependencies are satisfied

一个普通的bundle exec ruby 加载它就可以了:

/app # bundle exec ruby -e'require "rake"; p Rake::VERSION'
"12.3.1"

但是,Rails 控制台找不到它:

/app # bin/rails c
Could not find rake-12.3.1 in any of the sources
Run `bundle install` to install missing gems.

/app # bundle exec bin/rails c
Could not find rake-12.3.1 in any of the sources
Run `bundle install` to install missing gems.

我错过了什么?

【问题讨论】:

  • 你能显示bundle list的结果吗?
  • 我不确定发生了什么,但bundle exec rails c 应该可以工作。
  • 终端中显示的默认 ruby​​ 版本是什么,确保在执行 $rails c 时显示相同的 ruby​​ 版本。你在使用任何 gemset 吗?
  • 可以添加bin/rails文件的内容吗?

标签: ruby-on-rails ruby bundler


【解决方案1】:

Spring 是否在您的 rails 版本中初始化?如果是这样,请尝试禁用 Spring rails 应用程序预加载器:

DISABLE_SPRING=true rails c

【讨论】:

    【解决方案2】:

    这是在将BUNDLE_PATH 设置为/gems 的Docker 容器内。我打开了一个shell,把/gems下的所有内容都删了,重新打包,现在可以了。

    我很想了解发生了什么,但现在我要继续前进了。

    【讨论】:

      猜你喜欢
      • 2014-06-28
      • 2016-12-31
      • 1970-01-01
      • 1970-01-01
      • 2020-06-19
      • 1970-01-01
      • 2012-06-24
      • 2016-11-24
      • 1970-01-01
      相关资源
      最近更新 更多