# Rails 3 beta 2 won't load mysql gem

**URL:** <https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294>\
**Category:** Rails\
**Created:** [April 3, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294 "2010-04-03T22:19:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@ngng](https://www.ruby-forum.com/u/ngng)\
**Post date:** [April 3, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294/1 "2010-04-03T22:19:21Z")

</div>

Hi all,

I decided to try out Rails 3 and immediately ran into big issues… I  
am using ruby-1.8.7-p249 compiled with rvm on Ubuntu 9.10 and followed  
the install instructions for Rails 3 from

> **[rails.info](http://guides.rails.info/3_0_release_notes.html)**
>
> Ruby on Rails,Rails Tutorial,Ruby Basics,Rails 4,Bar Rails,Rail

My first issue was it required me to install the sqlite3-ruby gem  
despite changing the adapters in config/database.yml. After trying to  
find a way around this I gave up and just installed the extra gem.  
After this, doing a rake db:create caused this error:

:~/rails\_app$ rake db:create  
(in -snip-/rails\_app)  
!!! Please install the mysql gem and try again: gem install mysql.  
rake aborted!  
no such file to load – mysql

The mysql gem is definitely installed, and correctly loads if I do the  
following:

:~/rails\_app$ irb  
ruby-1.8.7-p249 \> require ‘rubygems’  
=\> true  
ruby-1.8.7-p249 \> require ‘mysql’  
=\> true

So I’m stuck. Googling has not provided any answers. Anyone figured  
this one out?

(Yes, ‘which rake’ shows it is loading the correct rake…)

---

<div class="post-metadata">

**Author:** ![ngng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@ngng](https://www.ruby-forum.com/u/ngng)\
**Post date:** [April 3, 2010, 11:00pm UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294/2 "2010-04-03T23:00:19Z")

</div>

On Sat, Apr 3, 2010 at 9:22 AM, Jonathan N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> After this, doing a rake db:create caused this error:  
> :~/rails\_app$ irb

What does the following say?

$ gem environment  
$ gem list mysql

BTW, I was able to install on both Linux and Mac OS using the following  
combinations:

Ruby 1.8.7/1.9.2, Rails 3.0 beta, Linux  
Ruby 1.8.7/1.9.2, Rails 3.0 beta, Mac OS

-Conrad

---

<div class="post-metadata">

**Author:** ![ngng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@ngng](https://www.ruby-forum.com/u/ngng)\
**Post date:** [April 4, 2010, 2:12am UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294/3 "2010-04-04T02:12:21Z")

</div>

“Jonathan N.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote  
in message  
news:removed\_email\_address@domain.invalid…

> After this, doing a rake db:create caused this error:
> 
> :~/rails\_app$ rake db:create  
> (in -snip-/rails\_app)  
> !!! Please install the mysql gem and try again: gem install mysql.  
> rake aborted!  
> no such file to load – mysql

As I understand it, you need to add the mysql gem to the Gemfile, and  
run  
“bundle install”. Rails 3 projects only look for gems in the .bundle  
directory. The bundler reads the gemfile, and then either creates links  
in  
the $appdir/.bundle directory to the system gems, or downloads them and  
installs them into the $appdir/.bundle directory. The whole idea is to  
allow  
installing gems that only one project needs into the project directory,  
rather than into the system gem repository, especally since the latter  
requires superuser permissions in many operating systems, but while  
doing so  
to use the system gems when possible to avoid duplication.

---

<div class="post-metadata">

**Author:** ![ngng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@ngng](https://www.ruby-forum.com/u/ngng)\
**Post date:** [April 3, 2010, 11:16pm UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294/4 "2010-04-03T23:16:42Z")

</div>

> What does the following say?
> 
> $ gem environment  
> RubyGems Environment:

- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
- INSTALLATION DIRECTORY: /-snip-/.rvm/gems/ruby-1.8.7-p249
- RUBY EXECUTABLE: /-snip-/.rvm/rubies/ruby-1.8.7-p249/bin/ruby
- EXECUTABLE DIRECTORY: /-snip-/.rvm/gems/ruby-1.8.7-p249/bin
- RUBYGEMS PLATFORMS:
  - ruby
  - x86-linux

- GEM PATHS:
  - /-snip-/.rvm/gems/ruby-1.8.7-p249
  - /-snip-/.rvm/gems/ruby-1.8.7-p249@global

- GEM CONFIGURATION:
  - :update\_sources =\> true
  - :verbose =\> true
  - :benchmark =\> false
  - :backtrace =\> false
  - :bulk\_threshold =\> 1000
  - :sources =\> [“[http://gems.rubyforge.org/](http://gems.rubyforge.org/)”, “http://  
[gems.github.com](http://gems.github.com)”]

- REMOTE SOURCES:
  - [http://gems.rubyforge.org/](http://gems.rubyforge.org/)
  - [http://gems.github.com](http://gems.github.com)

> $ gem list mysql  
> \*\*\* LOCAL GEMS \*\*\*  
> mysql (2.8.1)  
> mysqlplus (0.1.1)

I’ve tried uninstalling mysqlplus (which I use in a different project)  
and it doesn’t make a difference.

-Jonathan N.

---

<div class="post-metadata">

**Author:** ![ngng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@ngng](https://www.ruby-forum.com/u/ngng)\
**Post date:** [April 4, 2010, 3:47am UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294/5 "2010-04-04T03:47:10Z")

</div>

> As I understand it, you need to add the mysql gem to the Gemfile, and run  
> “bundle install”. Rails 3 projects only look for gems in the .bundle  
> directory.

Oh wow, I didn’t see the gemfile at all… thanks for pointing me to  
that. That looks like the solution to my problem, thanks!

-Jonathan N.

---

<div class="post-metadata">

**Author:** ![ngng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@ngng](https://www.ruby-forum.com/u/ngng)\
**Post date:** [April 4, 2010, 5:13am UTC](https://www.ruby-forum.com/t/rails-3-beta-2-wont-load-mysql-gem/186294/6 "2010-04-04T05:13:47Z")

</div>

On Sat, Apr 3, 2010 at 6:46 PM, Jonathan N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > As I understand it, you need to add the mysql gem to the Gemfile, and run  
> > “bundle install”. Rails 3 projects only look for gems in the .bundle  
> > directory.
> 
> Oh wow, I didn’t see the gemfile at all… thanks for pointing me to  
> that. That looks like the solution to my problem, thanks!
> 
> -Jonathan N.

Yes, Rails 3 is a bit stricter in application development where you need  
to  
specify  
which gems are being used by the application in the Gemfile. I would  
recommend  
working through the Rails guides as well as getting comfortable with the  
Bundler gem.

Good luck,

-Conrad
