问题描述
我们刚刚将ruby更新为2.6,并将bundler更新为2。现在我们得到:
We've just updated ruby to 2.6 and bundler to 2. Now we're getting:
# bin/rails console
You must use Bundler 2 or greater with this lockfile.
这以前是与 bundle exec
一起发生的:
This was previously happening with bundle exec
:
# bundle exec rails console
You must use Bundler 2 or greater with this lockfile.
那时我们默认仍在运行1.17.2:
At that point we were still running 1.17.2 by default:
# gem list bundler
*** LOCAL GEMS ***
bundler (2.0.1, default: 1.17.2)
所以我们运行了 gem卸载捆绑程序--version 1.17.2
,然后 bundle exec
开始工作。
So we ran gem uninstall bundler --version 1.17.2
and then bundle exec
started working.
但是<$ c像 bin / rails
这样的$ c> bin 存根仍然失败。
But the bin
stubs like bin/rails
are still failing.
如何
推荐答案
The b会在运行 1.17.2
时被卸载吗?在您的答案中诊断似乎正确。但是看来您可以通过在要求之前添加此 来激活最新安装的Bundler gem(由
行: gem install bundler
安装)。 'bundler / setup'
The diagnose in your answer seems right. But it seems you can activate the latest installed Bundler gem (installed by gem install bundler
) by adding this before the require 'bundler/setup'
line:
Gem::Specification.find_by_name('bundler').activate
如果需要,还可以使用更具体的版本要求。例如:
More specific version requirements can also be used if needed. For example:
Gem::Specification.find_by_name('bundler', '~> 2.0.1').activate
find_by_name
抛出 LoadError
如果找不到gem,则派生异常。
find_by_name
throws LoadError
derived exception if the gem is not found.
这篇关于捆绑器版本不匹配-捆绑器2,Ruby 2.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!