【问题标题】:I have Bundler 2, yet Ruby/Rails says is missing?我有 Bundler 2,但 Ruby/Rails 说不见了?
【发布时间】:2021-02-21 20:18:26
【问题描述】:

启动 localhost,我在终端中输入“rails s”。我收到此错误:

Traceback (most recent call last):
    5: from bin/rails:3:in `<main>'
    4: from bin/rails:3:in `load'
    3: from /Users/macbookpro/flippingUnleashedCRM/bin/spring:10:in `<top (required)>'
    2: from /Users/macbookpro/flippingUnleashedCRM/bin/spring:10:in `new'
    1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)

所以,我输入bundler --version 以查看我在使用什么。结果是:

Bundler version 2.2.11

我查看了我的 Gemfile.lock,向下滚动,我看到了:

RUBY VERSION
   ruby 2.5.1p57

BUNDLED WITH
   2.2.11

到底是什么问题?

【问题讨论】:

  • 不确定,但错误是针对 Ruby 2.6 (Ruby.framework/Versions/2.6) 而您的 Gemfile.lock 是针对 Ruby 2.5.1。尝试停止您的 spring 服务器。您可能还有过时的弹簧包装。尝试removing 并重新安装它们。
  • ^ 对我有用的是绕过 Spring。我按照此链接中的第 1 步和第 2 步进行操作,并且成功了。感谢您提供一些好的指示。 fuzzyblog.io/blog/rails/2017/03/20/…

标签: ruby-on-rails ruby bundler rails-spring


【解决方案1】:

这里似乎有几件事可能出错:

要解决您当前的问题,请尝试运行bundle exec rails s。这将在context of your bundle 中运行rails。

其次,您还应该确保您的 Ruby 版本与指定的版本相匹配。就像提到的另一条评论一样,您似乎在 Ruby 2.5 上的项目上运行 Ruby 2.6。像 chruby 这样的 Ruby 版本管理器将帮助您更好地管理 Ruby 版本和每个版本的 gem 依赖项。

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 1970-01-01
    • 2017-08-19
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-14
    相关资源
    最近更新 更多