I am sure I am missing something... can someone please point me to the right direction as I feel I have been chasing my tail for the last few hours.

PROBLEM I am able to run rvm, mysql and Rails but as soon as I add Bundler, it causes the following error.

=> Booting WEBrick => Rails 2.3.12 application starting on http://0.0.0.0:3000 !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.

TROUBLESHOOTING ATTEMPTS

None of the below have worked.

  1. Re-installed mysql gem several times using v2.7 and the latest release (v2.8.1)

    ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

  2. Tried installing mysql2 gem and also renaming the adapter to mysql2 in the db.yml file

  3. Searched project for all instances that reference Rails 2.2 or mysql.rb and removed the gem/plugin

  4. If I remove the Bundler initialisation, my rails app starts without this error but fails as it can't recognise the gems.

SETUP

  • OSX Leopard
  • Bundler
  • rvm with gemset
  • MySQL Ver 14.14 Distrib 5.5.8, for osx10.6 (i386) using readline 5.1
  • Rails v2.3.12 (through rvm)
  • Ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-darwin10.6.0]

GEM LIST

actionmailer (2.3.12)
actionpack (2.3.12)
activerecord (2.3.12)
activeresource (2.3.12)
activesupport (2.3.12)
bundler (1.0.15)
columnize (0.3.4)
linecache (0.46)
mysql (2.8.1)
newrelic_rpm (3.1.0)
rack (1.1.2)
rails (2.3.12)
rake (0.9.2, 0.8.7)
rbx-require-relative (0.0.5)
ruby-debug (0.10.4)
ruby-debug-base (0.10.4)

The following appears in my boot.rb file before Rails.boot!:

class Rails::Boot
  def run
    load_initializer

    Rails::Initializer.class_eval do
      def load_gems
        @bundler_loaded ||= Bundler.require :default, Rails.env
      end
    end

    Rails::Initializer.run(:set_load_path)
  end
end

I have the following config/preinitializer.rb file:

begin
  require "rubygems"
  require "bundler"
rescue LoadError
  raise "Could not load the bundler gem. Install it with `gem install bundler`."
end

if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
  raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
   "Run `gem install bundler` to upgrade."
end

begin
  # Set up load paths for all bundled gems
  ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
  Bundler.setup
rescue Bundler::GemNotFound
  raise RuntimeError, "Bundler couldn't find some gems." +
    "Did you run `bundle install`?"
end

THE SOLUTION

I was installing mysql gem prior to installing bundler. This was causing the problem with bundler. So instead, I added mysql gem to my gemfile and ran the below line before running bundle install

bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
link|improve this question
feedback

migrated from stackoverflow.com Jul 12 '11 at 15:15

This question came from our site for professional and enthusiast programmers.

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.