Ruby-on-rails Bundler 找不到 gem "bundler" 的兼容版本:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9854225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 03:06:09  来源:igfitidea点击:

Bundler could not find compatible versions for gem "bundler":

ruby-on-railsrubybundlerbundle

提问by audioeric

Complete new person to Ruby and Rails here... Have tried some tutorials in the past, but that's about it. I'm trying to follow 'Ruby on Rails 3 Tutorial' book and have hit a roadblock that I haven't been able to find any help for after searching on here and the Google..

这里是 Ruby 和 Rails 的新人...过去曾尝试过一些教程,但仅此而已。我正在尝试遵循“Ruby on Rails 3 教程”一书,但遇到了一个障碍,在此处和 Google 上搜索后,我无法找到任何帮助。

I haven't actually done anything yet; only:

我实际上还没有做任何事情;只要:

rails new first_app

then changed the Gemfile sqlite3 to

然后将 Gemfile sqlite3 更改为

gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

When I run 'bundle install' I get the following:

当我运行“捆绑安装”时,我得到以下信息:

Fetching gem metadata from http://rubygems.org/.........
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    rails (= 3.0.1) ruby depends on
      bundler (~> 1.0.0) ruby

  Current Bundler version:
    bundler (1.1.3)

This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

I've tried uninstalling the bundler via

我尝试通过以下方式卸载捆绑程序

gem uninstall bundler -v 1.1.3

and then installing bundler v1.0.0 via

然后通过安装bundler v1.0.0

gem install bundler -v 1.0.0

but it seems to get me bundler 1.1.2..

但它似乎让我捆绑了 1.1.2 ..

I just feel like I've hit a dead end and can't find any more information on how to solve this issue.

我只是觉得我陷入了死胡同,找不到有关如何解决此问题的更多信息。

Any help would be greatly appreciated and rewarded with copious amounts of bacon...

任何帮助将不胜感激,并以大量培根作为奖励......

UPDATE UPDATE UPDATE

更新更新更新

I couldn't get bundler v 1.1.2 to uninstall. I finally was able to uninstall all of the gems by doing:

我无法卸载 bundler v 1.1.2。我终于能够通过执行以下操作卸载所有宝石:

sudo gem list | cut -d" " -f1 > gem_list.txt  
cat gem_list.txt | xargs sudo gem uninstall -aIx  
cat gem_list.txt | xargs sudo gem install

And then reinstalling... This allowed me to then do the 'bundle install' and get on track.. Thank you all for your help!

然后重新安装......这让我可以进行“捆绑安装”并走上正轨......谢谢大家的帮助!

采纳答案by joelparkerhenderson

First verify your versions to be sure they're all current:

首先验证您的版本以确保它们都是最新的:

$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]

$ rails -v          
Rails 3.2.2

$ gem list bundler
*** LOCAL GEMS ***
bundler (1.1.3)

If you need to update ruby, you can download it from https://www.ruby-lang.orgor use tools like ruby-build. If you have any version of Ruby 1.9.3 that's fine for now.

如果需要更新 ruby​​,可以从https://www.ruby-lang.org下载或者使用 ruby​​-build 之类的工具。如果您有任何 Ruby 1.9.3 版本,现在就可以了。

To update all your gems:

要更新您的所有宝石:

gem update --system
gem update

Gem may install gems in a few different places, and these can interfere with each other. There are system gems (typically installed by root or by using sudo) and your personal user gems. My favorite way to manage these is with a simple tool called rbenv. A related tool is rvm. Either is fine.

Gem 可能会在几个不同的地方安装 gem,这些可能会相互干扰。有系统 gems(通常由 root 或使用 sudo 安装)和您的个人用户 gems。我最喜欢的管理方式是使用一个名为 rbenv 的简单工具。一个相关的工具是 rvm。哪个都好。

For your first tutorial, you can skip using version numbers in your Gemfile:

对于您的第一个教程,您可以跳过在 Gemfile 中使用版本号:

- gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
+ gem 'sqlite3-ruby', :require => 'sqlite3'

Bundler will sort everything out the right way. Eventually you'll want to specify version numbers if you're coordinating with other developers, or building production systems.

Bundler 会以正确的方式解决所有问题。最终,如果您要与其他开发人员协调或构建生产系统,您将需要指定版本号。

Feel free to ask questions here and I'll add to this answer.

随意在这里提问,我会添加到这个答案中。

回答by Neeraj Kumar

it is because gems are also installed in global gemset, and you can uninstall it using:

这是因为 gems 也安装在全局 gemset 中,您可以使用以下命令卸载它:

rvm @global do gem uninstall bundler

but you can also use the other version of bundler using:

但您也可以使用其他版本的 bundler:

gem install bundler -v '~>1.0.0'
bundle _1.0.0_ install

replace 1.0.0 with the version that got installed (if other)

将 1.0.0 替换为已安装的版本(如果其他)

回答by Aurélien Bottazini

Maybe you had bundler 1.1.2 AND 1.1.3 installed on your machine (and possibly more versions)

也许您的机器上安装了 bundler 1.1.2 和 1.1.3(可能还有更多版本)

use

gem list bundler

to check which version(s) of bundler you have installed.

检查您安装了哪个版本的 bundler。

Then remove the ones you don't want with

然后删除你不想要的那些

gem uninstall bundler -v VERSION_NUMBER

回答by MikDiet

You can use latest version of Rails 3.0 (3.0.12). It supports latest bundler, and isn't fundamentally differ from 3.0.1

您可以使用最新版本的 Rails 3.0 (3.0.12)。它支持最新的捆绑器,与 3.0.1 没有根本区别

回答by Asbj?rn Ulsberg

I had this problem and the source was a version specification for bundlerin the .gemspecfile:

我有这个问题,来源是一个版本规范bundler.gemspec的文件:

spec.add_development_dependency "bundler", "~> 1.16"

Removing the version number solved the issue:

删除版本号解决了这个问题:

spec.add_development_dependency "bundler"

回答by user3259695

Bundler is a dependent gem of rails, because of which you can see it only in gemfile.lockinstead of gemfile.

Bundler 是一个依赖于 rails 的 gem,因此你只能在gemfile.lock而不是gemfile.

For a particular rails version only a range of bundler gems are compatible. I also got this error and I tried uninstalling that version of bundler gem which I didn't need. I also tried to install forcefully using bundle_x.x.x_install, but when things didn't work I explicitly mentioned the gem specifying the version falling within the range required by rails version I am using. May be it's not the right way but that is how things worked for me.

对于特定的 rails 版本,只有一系列的 bundler gem 是兼容的。我也遇到了这个错误,我尝试卸载我不需要的那个版本的 bundler gem。我还尝试使用 强制安装bundle_x.x.x_install,但是当事情不起作用时,我明确提到了 gem 指定的版本落在我正在使用的 rails 版本要求的范围内。可能这不是正确的方式,但这就是我的工作方式。

回答by Roman Podymov

Sometimes to fix the issue mentioned in the title of this question it is enough to delete Gemfile.lock and run bundle update. I hope it will be helpful for someone.

有时要解决这个问题标题中提到的问题,删除 Gemfile.lock 并运行bundle update. 我希望它会对某人有所帮助。