31

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..

I haven't actually done anything yet; only:

rails new first_app

then changed the Gemfile sqlite3 to

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

gem install bundler -v 1.0.0

but it seems to get me 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. 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!

audioeric
  • 375
  • 1
  • 4
  • 9

7 Answers7

22

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

rvm @global do gem uninstall bundler

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

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

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

Neeraj Kumar
  • 6,045
  • 2
  • 31
  • 23
  • Just a note for anyone else, I had to install bundler version `1.0`, and it installed a slightly different version `1.17.3`, so I had to use `bundle _1.17.3_ install` and that worked – stevec Aug 01 '20 at 06:37
11

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

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
Aurélien Bottazini
  • 3,249
  • 17
  • 26
  • 3
    I had 3 versions installed, 1.0.0, 1.1.2, and 1.1.3. I can uninstall 1.0.0 and 1.1.3, but I can't uninstall 1.1.2. if I do gem uninstall bundler, it says bundler not installed. But if I do gem list bundler, it lists 1.1.2... – audioeric Mar 24 '12 at 18:33
11

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. If you have any version of Ruby 1.9.3 that's fine for now.

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.

For your first tutorial, you can skip using version numbers in your 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.

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

redfast00
  • 1,363
  • 1
  • 12
  • 23
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
  • Ruby is fine, I have 1.9.3p125. – audioeric Mar 24 '12 at 18:42
  • When I try to do rails -v I get that it currently isn't installed... Is there a way to just uninstall everything a do a fresh install of all of this? – audioeric Mar 24 '12 at 18:43
  • Alright, I uninstalled all of the gems via 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 that has allowed me to do the 'bundle install'... That solves the issue for now.. Thanks! – audioeric Mar 24 '12 at 18:56
  • Great, glad you're up and running! – joelparkerhenderson Mar 24 '12 at 19:01
7

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

mikdiet
  • 9,859
  • 8
  • 59
  • 68
2

I had this problem and the source was a version specification for bundler in the .gemspec file:

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

Removing the version number solved the issue:

spec.add_development_dependency "bundler"
Asbjørn Ulsberg
  • 8,721
  • 3
  • 45
  • 61
-1

Bundler is a dependent gem of rails, because of which you can see it only in gemfile.lock instead of 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.

Gorgsenegger
  • 7,356
  • 4
  • 51
  • 89
-2

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.

Roman Podymov
  • 4,168
  • 4
  • 30
  • 57