0

I am getting some errors whilst connecting to MySQL and the fixing of it led me to upgrade the mysql2 gem.

I ran this command to install mysql2:

ruby install mysql2 

and now "gem list" shows this gem: mysql2 (0.3.2)

But I think it isn't part of my application environment still since the server gives this error:

Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) 

I have RVM and I've used bundler to make a gemset for this application. How can I add mysql2 to this application's gemset?

This is my gemfile:

source 'http://rubygems.org' gem 'rails', '3.0.7' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' gem 'mysql2' , '0.3.2' 

And this is my MySQL adapter version:

$bundle show mysql2 /home/agenadinik/workspace/udfr/mysql2/ruby/1.9.1/gems/mysql2-0.3.2 

Also

$ rvm gemdir /home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/gem:4: warning: Insecure world writable dir /home/agenadinik in PATH, mode 040777 /home/agenadinik/.rvm/gems/ruby-1.9.2-p180

3 Answers 3

7

Note that you cannot use mysql2 version 0.3.x with Rails version less than 3.1.x. I assume you are using Rails 3.0.x or below (and thus you need to use mysql2 version 0.2.x):

Here is an example of how to set up a gemset and the Gemfile to use mysql2:

~/code/myapp $ rvm gemset create myapp ~/code/myapp $ rvm use @myapp <<<<<Edit the Gemfile and add the line gem "mysql2","0.2.7" then save and exit editor.>>>>> ~/code/myapp $ bundle install ~/code/myapp $ bundle show mysql2 <<<<<Output should be similar to: /home/<your-name>/.rvm/gems/ruby-<some-version>@myapp/gems/mysql2-0.2.7>>>>> 
Sign up to request clarification or add additional context in comments.

6 Comments

@Zabba You know, my mysql2 version is mysql2 (0.3.2) which showed after I ran bundle install. And then bundle show mysql2 command gave this message: Could not find gem 'mysql2 (= 0.2.7)' in any of the gem sources listed in your Gemfile.
@Zabba so I think my mysql2 is somehow not installed/not configured....right? But it seems I just went through all the install actions. CoNfUsEd :)
Please post your Gemfile and the output of command rvm gemdir. Also, what is the gemset name you created? Also, in which directory are you running bundle install (i.e. what is the pwd) and does the Gemfile in that directory contain the line gem "mysql2", "0.2.7" ? And what is output of command rvm current.
@Zabba just edited by original question with the info you posted
I see that you did not follow the steps I have outlined in my answer. Also you have not answered all the questions I asked in my comment above.
|
3

If you're using Bundler, you should add

gem "mysql2" 

to your Gemfile, then run bundle install

1 Comment

That didn't really fix things. I am trying Zabba's example now :) Will report what happens :)
0

On Rails >= 3.2.0 you will see this if you are using an older version of bundler. Update bundler to >= 1.1.1:

gem update bundler 

Once you have done this, update your gems:

bundle install 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.