简体   繁体   中英

Bundler won't install mysql2

First of all I've gone through dozens of posting here on SO and google and haven't been able to find an answer. I'm trying to install mysql2 with bundler and it won't do it.

Running on Ubuntu Server 11.04 Natty

Here's some background info:

ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]

gem -v
1.8.24

rails -v
Rails 3.2.5

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.62, for debian-linux-gnu (x86_64) using readline 6.2

I have gem "mysql2", "~> 0.3.11" in my Gemfile

When I do bundle install it goes through the process and it finishes successfully ( No Errors ) but it doesn't install mysql2. When I do bundle show , mysql2 is not listed.

I've tried a gazillion of things recommended here and on forums and still can't get mysql2 to install with bundler.

Any ideas?

Thanks.

For mysql2 you need to install the dev files on your server.

try first:

sudo apt-get install libmysqlclient-dev

Then check first your GemFile in your RoR App Dir - I have this line in my GemFile:

gem 'mysql2', '0.3.11'

run bundle:

bundle install

or try the command from Emily first then run bundle install:

gem install mysql2 -v=0.3.11
bundle install

I hope it helps

So after many tries, reading, and pulling my hair out I found out what was the problem, so I'm posting it for those that might run into the same situation.

The reason why bundler wouldn't install mysql2 is because the gem was inside this platforms structure, see below:

platforms :mri_19, :mingw_19 do
  group :mysql do
    gem "mysql2", "0.3.11"
  end
end

So all I did was to move just gem "mysql2", "0.3.11" by itself to the top of the Gemfile and run bundle install and that did it! Now mysql2 is listed under bundle show and my rails application is running now.

Thanks every one that tried to help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM