【问题标题】:Rails console: You must use Bundler 2 or greater with this lockfileRails 控制台:您必须使用 Bundler 2 或更高版本与此锁定文件
【发布时间】:2021-09-16 05:30:11
【问题描述】:

我正在尝试在 OpenAppAcademy 中开始学习 Ruby On Rails,但是当我在 18.04 Ubuntu rails console 的终端上运行时,我得到了

/var/lib/gems/2.5.0/gems/railties-6.1.4.1/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Traceback (most recent call last):
        5: from bin/rails:3:in `<main>'
        4: from bin/rails:3:in `load'
        3: from /mnt/c/Users/RedmiBook/Desktop/projects/APPACADEMY/SQL/Active Record/Intro To Rails/bin/spring:10:in `<top (required)>'
        2: from /mnt/c/Users/RedmiBook/Desktop/projects/APPACADEMY/SQL/Active Record/Intro To Rails/bin/spring:10:in `new'
        1: from /usr/lib/ruby/vendor_ruby/bundler/lockfile_parser.rb:95:in `initialize'
/usr/lib/ruby/vendor_ruby/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)

我的捆绑器高于版本 2,所以我尝试sudo gem update --system

Installing RubyGems 3.2.27
Traceback (most recent call last):
        3: from setup.rb:22:in <main>'
        2: from setup.rb:22:in require'
        1: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.27/lib/rubygems.rb:1328:in <top (required)>'
/var/lib/gems/2.5.0/gems/rubygems-update-3.2.27/lib/rubygems.rb:1341:in rescue in <top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
Loading the rubygems/defaults/operating_system.rb file caused an error. This file is owned by your OS, not by rubygems upstream. Please find out which OS package this file belongs to and follow the guidelines from your OS to report the problem and ask for help.

我真的不知道从这里开始,很遗憾我不能开始使用 Rails。

【问题讨论】:

  • 我显然是一个初学者,不要冒犯我,我愿意接受任何建设性的批评
  • gem list | grep bundler 命令的输出是什么?
  • 捆绑器(2.2.27、2.2.24、2.2.21、1.16.1)

标签: ruby-on-rails ruby ruby-on-rails-5


【解决方案1】:

根据您安装 ruby​​ 的方式(rvmrbenvasdf、系统级安装),您可能需要在您的 ruby​​ 命令前添加 bundle exec

bundle exec rails console

这种方式 bundle 将限制执行到您的 Gemfile.lock 中声明的 gem,可能包括 bundle 版本。

您可能已全局安装了 rails 可执行文件,它可能使用不同版本的 ruby​​ 和 ruby​​gems。


更新(关于以用户友好的方式安装 ruby​​ 的痛苦):

我绝对建议您安装一些用户级工具链,例如 rvmasdf 并完全控制 ruby​​ 版本。你不应该sudo 任何东西来运行 ruby​​ 和 rails 应用程序。

访问 rvm 或 asdf 站点并按照说明将它们安装到您的操作系统中,您的 ruby​​ 将得到控制。

【讨论】:

    猜你喜欢
    • 2019-04-13
    • 2020-04-14
    • 2020-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-20
    • 1970-01-01
    • 2019-09-18
    相关资源
    最近更新 更多