安装了 Bundler 2.0.1,Rails 说“必须使用 Bundler 2 或更高版本"? [英] Bundler 2.0.1 installed, Rails says "must use Bundler 2 or greater"?

查看:24
本文介绍了安装了 Bundler 2.0.1,Rails 说“必须使用 Bundler 2 或更高版本"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名 Rails 新手,正在 DigitalOcean 液滴上试用 Rails.安装似乎工作正常,但是当我尝试生成脚手架时收到一条奇怪的错误消息:

DO 10:48 Rails/simple (master) → rails generate scaffold User name:string email:string回溯(最近一次通话最后):5:来自 bin/rails:3:in `<main>'4:来自 bin/rails:3:in `load'3:来自/home/tony/rails/simple/bin/spring:10:in `<top (required)>'2:来自/home/tony/rails/simple/bin/spring:10:in `new'1:来自/home/tony/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize'/home/tony/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version':您必须在此锁定文件中使用 Bundler 2 或更高版本.(Bundler::LockfileError)DO 10:49 Rails/simple (master) → bundle list bundler/home/tony/.rvm/gems/ruby-2.6.0/gems/bundler-2.0.1DO 10:50 Rails/simple (master) → gem list bundler*** 当地宝石 ***捆绑器(2.0.1,默认值:1.17.2)捆绑器卸载 (1.0.2)rubygems 捆绑器 (1.4.5)

即,当前的 Bundler gem 是 2.0.1 版本,但 Rails 仍然认为它不够.

我在网上找不到类似的东西.我能看到的唯一危险信号是捆绑器 gem 显示默认版本 1.17.2.如何开始诊断问题?

解决方案

我遇到了同样的问题 &通过使用 gem uninstall bundler 降级解决它,然后使用 gem install bundler -v 1.17.3 恢复到最后的 pre 2 版本.

我在 3 个使用不同版本管理器(ASDF、rbenv、rvm)的独立系统中看​​到了这一点,这解决了这个问题.

有一些关于让两个版本都能很好玩的信息 这里.此问题的根本原因可能是一个错误(似乎已经修复)

根据下面@MatijsvanZuijlen 的评论和捆绑器文档,您还应该能够通过 bundle _1.17.3_ install

I'm a Rails newb who's trying out Rails on a DigitalOcean droplet. The installations seemed to work fine, but I'm getting a curious error message when I try to generate a scaffold:

DO 10:48 Rails/simple (master) → rails generate scaffold User name:string email:string
Traceback (most recent call last):
        5: from bin/rails:3:in `<main>'
        4: from bin/rails:3:in `load'
        3: from /home/tony/rails/simple/bin/spring:10:in `<top (required)>'
        2: from /home/tony/rails/simple/bin/spring:10:in `new'
        1: from /home/tony/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize'
/home/tony/.rvm/rubies/ruby-2.6.0/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)
DO 10:49 Rails/simple (master) → bundle list bundler
/home/tony/.rvm/gems/ruby-2.6.0/gems/bundler-2.0.1
DO 10:50 Rails/simple (master) → gem list bundler

*** LOCAL GEMS ***

bundler (2.0.1, default: 1.17.2)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)

I.e., the current Bundler gem is version 2.0.1, but Rails still thinks it's insufficient.

I can't find anything similar on the web. The only red flag I can see is that the bundler gem shows a default version of 1.17.2. How do I begin to diagnose the problem?

解决方案

I ran into the same issue & resolved it by downgrading with gem uninstall bundler, followed by gem install bundler -v 1.17.3 to revert back to the last pre 2 version.

I saw this across 3 separate systems using different version managers (ASDF, rbenv, rvm) and this resolved the issue.

There is some information on getting both versions to play nicely here. The root cause of this issue may have been a bug (which appears to have since been fixed)

Per the comment from @MatijsvanZuijlen below, and the bundler documentation, you should also be able to specify which version of bundler you want to use at runtime with bundle _1.17.3_ install

这篇关于安装了 Bundler 2.0.1,Rails 说“必须使用 Bundler 2 或更高版本"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆