ruby-on-railsrubybundlergem-bundler

Failed generating controller due to Bundler version conflict


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.


Solution

  • 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