简体   繁体   English

Bundler 找不到 gem“bundler”的兼容版本:

[英]Bundler could not find compatible versions for gem "bundler":

Complete new person to Ruby and Rails here... Have tried some tutorials in the past, but that's about it.在这里完成 Ruby 和 Rails 的新人......过去尝试过一些教程,但仅此而已。 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 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..但它似乎让我得到了 bundler 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.我无法卸载 bundler v 1.1.2。 I finally was able to uninstall all of the gems by doing:我终于能够通过执行以下操作卸载所有宝石:

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!然后重新安装...这让我可以进行“捆绑安装”并步入正轨..谢谢大家的帮助!

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替换为已安装的版本(如果是其他)

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.org or use tools like ruby-build. 如果您需要更新ruby,可以从https://www.ruby-lang.org下载或使用ruby-build等工具。 If you have any version of Ruby 1.9.3 that's fine for now. 如果您有任何版本的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. 有系统宝石(通常由root或使用sudo安装)和您的个人用户宝石。 My favorite way to manage these is with a simple tool called rbenv. 我最喜欢的管理方法是使用一个名为rbenv的简单工具。 A related tool is rvm. 一个相关的工具是rvm。 Either is fine. 要么没事。

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. Bundler将以正确的方式排序所有内容。 Eventually you'll want to specify version numbers if you're coordinating with other developers, or building production systems. 最终,如果您正在与其他开发人员协调或构建生产系统,则需要指定版本号。

Feel free to ask questions here and I'll add to this answer. 随意在这里提问,我将添加到这个答案。

Maybe you had bundler 1.1.2 AND 1.1.3 installed on your machine (and possibly more versions) 也许您的机器上安装了bundler 1.1.2 AND 1.1.3(可能还有更多版本)

use 使用

gem list bundler

to check which version(s) of bundler you have installed. 检查您安装的捆绑器的版本。

Then remove the ones you don't want with 然后删除你不想要的那些

gem uninstall bundler -v VERSION_NUMBER

You can use latest version of Rails 3.0 (3.0.12). 您可以使用最新版本的Rails 3.0(3.0.12)。 It supports latest bundler, and isn't fundamentally differ from 3.0.1 它支持最新的捆绑包,并没有从根本上与3.0.1不同

I had this problem and the source was a version specification for bundler in the .gemspec file:我遇到了这个问题,来源是bundler文件中捆绑.gemspec的版本规范:

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

Removing the version number solved the issue:删除版本号解决了这个问题:

spec.add_development_dependency "bundler"

Sometimes to fix the issue mentioned in the title of this question it is enough to delete Gemfile.lock and run bundle update . 有时为了解决这个问题标题中提到的问题,删除Gemfile.lock并运行bundle update就足够了。 I hope it will be helpful for someone. 我希望它会对某人有所帮助。

Bundler is a dependent gem of rails, because of which you can see it only in gemfile.lock instead 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. 我也遇到了这个错误,我尝试卸载我不需要的那个版本的bundler gem。 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. 我还尝试使用bundle_x.x.x_install强力安装,但是当事情不起作用时,我明确提到了gem,指定版本属于我正在使用的rails版本所需的范围。 May be it's not the right way but that is how things worked for me. 可能它不是正确的方式,但这就是事情对我有用的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM