Bundler won't install mysql2

百般思念 提交于 2019-12-07 08:19:39

问题


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.


回答1:


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




回答2:


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!



来源:https://stackoverflow.com/questions/11004565/bundler-wont-install-mysql2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!