0

I'm starting to experiment with Rails 4 for work where we are using the MySQL2 3.1.0 gem on the server.

Locally with Ruby 2.0, I installed the MySQL2 3.1.0 Gem and everything was fine there (matching the gem version on the work server basically just to match the production server environment).

When I created a new Application (ruby new r4_test -d mysql) I ran into a problem though. Bundler crashed during the new application creation process complaining about missing MySQL2 3.1.3 files. It looks like 3.1.3 (released 3 months ago if I'm looking right) is the highest version number of the MySQL2 Gem. I'm confused about this because the only version of MySQL2 installed in the Ruby folder is version 3.1.0. Why did Bundler ignore the installed gem and expect a higher version that wasn't installed locally? I skipped Rails3 so I'm new to Bundler. It doesn't seem like it should expect a version that's not local though. Sometimes there are bugs or other issues where you need to stay on an older version of a gem for awhile too. ?

Thanks!

Reno
  • 2,962
  • 9
  • 41
  • 68

1 Answers1

0

If you don't already have a Gemfile.lock in your project directory, Bundler tries to install the most recent version available that meets the version criteria in Gemfile. So, for a new Rails project, it will try to install the latest dependencies of the default generated Gemfile. It doesn't actually look at your installed gems at all unless you already have a Gemfile.lock.

You can use the --skip-bundle (or -B) if you don't want Rails to run bundle install when creating a new project. That gives you a chance to customize the Gemfile first. You can add in a version constraint if you want to be sure it will use the version you already have installed.

Tim Moore
  • 8,958
  • 2
  • 23
  • 34