警告:Bundler 的 运行 版本早于创建锁定文件错误的版本

Warning: the running version of Bundler is older than the version that created the lockfile error

当我 developing/testing 时,我的控制台中一直出现此错误

Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.

它根本不是在阻止我,而是在窃听我。我知道最简单的解决方案就是将我的 Gemfile.lock 更新为此。

BUNDLED WITH
   2.1.2

但我想永久解决这个问题。我试着

gem uninstall bundler

然后

gem install bundler -v 2.1.4

它让我一直报这个错误

Gem bundler-2.1.2 cannot be uninstalled because it is a default gem

当我尝试先安装 2.1.4 然后删除 bundler 2.1.2 控制台时给我这个输出。

Gem bundler-2.1.2 cannot be uninstalled because it is a default gem
Successfully uninstalled bundler-2.1.4

这个问题有什么解决办法吗?提前致谢

就运行gem install bundler:2.1.4,别担心ruby自带的老版本,应该用不到

根据 Anne van Rossum 的说法, gem更新--系统 为我解决了这个问题。

我修好了!如果您使用的是 rvm,那么您必须转向您在该特定项目上使用的 ruby 版本(例如 'rvm use 2.7.0'),然后是 运行 'gem update --system'

您需要执行以下操作以确保将正确的默认版本的 Bundler 用于您正在使用的存储库。

  1. 您可以 运行 以下内容,但这可能会出现问题,因为它可能会破坏您系统上的本地 gem,因为所有这些都已更新.

    gem update --system
    
  2. 以下方法是确保更新 Bundler 的更安全的方法

  • 获取您的 gem 环境并记下 INSTALLATION_DIRECTORY
    gem environment
    
  • 然后运行以下
    cd <INSTALLATION DIRECTORY>/specifications/default
    rm bundler-<old_default_version>.gemspec
    gem install --default bundler -v <new_default_version>
    
  1. 如果你已经关注了 2 但还是不行,那么 运行
    gem install bundler:<new_default_version>
    
    确保您的本地存储库使用正确的版本

我删除了 gemfile.lock 文件,然后再次捆绑以构建新的依赖项。

https://github.com/rubygems/rubygems/issues/3202

另一种选择是更新到最新版本:

gem update bundler

除非有特定原因需要使用旧版本(例如,最新版本中存在错误,或者它们不再兼容),否则您可以按照警告消息安装该特定版本:

Warning: the running version of Bundler (2.2.32) is older than the version that created the lockfile (2.3.4). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.3.4.

gem install bundler:2.3.4