Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails mysql gem problem on ubuntu

Ruby on Rails: I would like to call a controller on the localhost, but the server said !!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql', '2.8.1'

The problem ? When I hit 'gem list' command then I got a list witch is containing the mysql 2.8.1 . So the gem is INSTALLED ! WHY can't it see by the webrick ?

Thank you.

like image 365
narancs Avatar asked Dec 12 '22 18:12

narancs


1 Answers

You need to add the line gem 'mysql', '2.8.1' to your Gemfile. Then type bundle install in the root folder of your Rails project. It sounds like you forgot to run bundler.

The MySQL gem does require native C extensions. So you'll need to make sure that you have all the development libraries installed.

In Ubuntu you can do something like this:

sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql

If you are using rvm, do not install gems as sudo.

Just to make sure, you might also want to try removing your Gemfile.lock and then re-running bundle install

like image 110
Dex Avatar answered Dec 26 '22 12:12

Dex