1

I'm learning Rails with tutorials from Ruby on Rails by Michael Hartl: https://www.railstutorial.org/book

I used the following command to generate a controller:

rails generate controller StaticPages home help

Which generates the following error regarding version conflicts:

check_version_conflict': can't activate bundler-1.12.4, already
activated bundler-1.13.0.pre.1 (Gem::LoadError)

I don't know which bundler version to use. The current version of bundler is: 1.13.pre.1


The following command continued failing due to about five gem dependencies that failed to install automatically, which included listen and nokigiri.

bundle install --without production

I tried installing the dependent gems manually, but I'm still having issues.

How do I resolve the check_version_conflict issue with Bundler when generating Rails controllers?

I'll accept an answer that instructs removing current Ruby libs and installing a new development environment from scratch.

SoAwesomeMan
  • 3,226
  • 1
  • 22
  • 25
Rajan
  • 312
  • 3
  • 13
  • Have you uninstalled bundler before trying to install it again? – Ed de Almeida Jun 26 '16 at 16:35
  • @EddeAlmeida how to do that ? – Rajan Jun 26 '16 at 16:35
  • 1
    run `gem uninstall bundler`, remove all versions and install the one of your choice. – Aleksei Matiushkin Jun 26 '16 at 16:37
  • 1
    As @mudasobwa said. It is much better than keep fighting against dependencies problems. – Ed de Almeida Jun 26 '16 at 16:38
  • that is easy, I removed the 1.13.pre.1 version, and there is no more conflict,just problem with the sass-rails gem but this is a different problem. do you know I can clean my setup and start fresh for setting up the setup again ? – Rajan Jun 26 '16 at 16:42
  • Start by removing your Gemfile.lock with `rm Gemfile.lock` and then run `bundle install` again. This will make bundler fetch the gems according to the dependencies. – Ed de Almeida Jun 26 '16 at 16:49
  • If you are using a specific bundle for this app you may remove this directory manually, go back to your app dir and run `bundle install` again. – Ed de Almeida Jun 26 '16 at 16:51
  • @EddeAlmeida I meant as uninstalling the rails set up; to much gem dependencies problem which is not mentioned in the book and I stand to be corrected but those gems that I need to instal manually supposed the core/default like listen, _callback, etc – Rajan Jun 26 '16 at 16:52
  • Are you using rvm or rbenv? – Ed de Almeida Jun 26 '16 at 16:53
  • The ideal is creating a specific bundle to you app. Much easier to handle and you'll get less conflicts in the future. http://rubyofftherails.blogspot.com/2016/02/different-bundles-for-different.html – Ed de Almeida Jun 26 '16 at 16:58
  • But I don't use rbenv and don't know how to do that with this version manager. – Ed de Almeida Jun 26 '16 at 16:59
  • Thank you very much for your help – Rajan Jun 26 '16 at 17:01

2 Answers2

2

Bundler will install project-specific versions of your gems so that you don't have to manage global dependencies.

In effect, if you install Rails with bundler and you also install it with sudo gem install rails or something like that, you'll have two versions on your computer. By default, calling rails will refer to the global version.

If you call bundle exec rails (or bundle exec <gem_name>), it will call the bundler-specific version.

max pleaner
  • 26,189
  • 9
  • 66
  • 118
  • the error state it was bundler version conflit, I've deleted a version of the bundler. Do you know how we can remove all the setup to start fresh ? (removing all the rails and stuff to start setting it up from beginning) cause it was to much problem at the beginning just want to make sure I'm having the right setup before going to far – Rajan Jun 26 '16 at 16:46
  • i think you'd just `gem uninstall rails` and stuff like that. Is stuff still not working after removing and reinstalling bundler? – max pleaner Jun 26 '16 at 16:52
1

Ten steps to resolve your issues with Bundler

  1. (optional) Uninstall Ruby. There are many ways to do so, here's one: https://superuser.com/questions/194051/how-to-completely-remove-ruby-ruby-gems-on-mac-os-x-10-6-4
  2. (optional) Use rbenv to install Ruby. Follow instructions here: https://github.com/rbenv/rbenv
  3. Make a repo directory that will house your future Rails app

From the command line:

mkdir repo
cd repo
  1. Install Bundler and create a Gemfile for the directory

From the command line:

gem install bundler
bundle init
  1. Open the repo/Gemfile with your editor, and configure it to instruct Bundler which version of Rails to install

In repo/Gemfile:

source "https://rubygems.org"                                

gem "rails", "4.2.6"
  1. Install Rails via Bundler

From the command line:

bundle install
  1. Create a new Rails app using Bundler, and cd into it

From the command line:

bundle exec rails new whatevs
cd whatevs
  1. Your Rails app will have a Gemfile by default. Open it and add the gems you wish to use in your app.

In repo/whatevs/Gemfile:

gem 'nokogiri', '1.6.8'
  1. From repo/whatevs/ directory, install your app's Gems via Bundler

From the command line:

bundle install
  1. From repo/whatevs/ directory, generate a controller

From the command line:

bundle exec rails generate controller static_pages home help
Community
  • 1
  • 1
SoAwesomeMan
  • 3,226
  • 1
  • 22
  • 25
  • 1
    thank you bro!! Awesom steps indeed, now I'm more aware of Rails and Bundler it turn out to be a normal matter. so basically I was using the bundle for first time (never exec bundle install before) and therefor most of the gems aren't installed. me being new to rails and now mention of every gem that is not installed yet will throw error during "bundle install" which require you to just install them and run bundle again (the error basically mean need to install a gem and not a big deal) got panick attack. – Rajan Jul 31 '16 at 11:28