views:

1253

answers:

5

I've written a rails app that's been running fine for a while without a database. Now, I'm dropping the registration database into the mix. It's not working in production. Everything works fine, of course, on my Mac.

Here's the production environment: - Ubuntu Hardy - Phusion Passenger - Rails 2.3.2

MySQL on the machine is running fine.

I have the database.yml file with the correct information. I can run the migrations with no problems:

rake db:migrate RAILS_ENV=production

The database is being correctly updated.

So, I hit tmp/restart and hit the site. I got the 500 error, but nothing was written to the production log (very odd). So, I checked the apache log, and I got this message:

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.

I have installed the MySQL gem (version 2.7). I'm still getting this error.

When I change the production database configuration to point to a dummy sqlite database, everything works fine. When I change it back to the MySQL configuration, I get the same error message.

I'm entirely out of ideas, and I wish that it would just work. I'm pulling my hair out, and I greatly appreciate any help you can provide. I've included everything I could think of, but please let me know if any more information would be useful.

Thanks!

Jason

A: 

Have you tried installing the mysql gem via sudo?

Mr. Matt
Yep. I actually installed it as root. Here's the gem list:*** LOCAL GEMS ***actionmailer (2.3.2)actionpack (2.3.2)activerecord (2.3.2)activeresource (2.3.2)activesupport (2.3.2)builder (2.1.2)configuration (0.0.5)cucumber (0.2.2)diff-lcs (1.1.2)fastthread (1.0.5)feedtools (0.2.29)hoe (1.11.0)launchy (0.3.3)memcache-client (1.7.0)mysql (2.7)passenger (2.1.2)polyglot (0.2.5)rails (2.3.2)rake (0.8.4)rspec (1.2.2)rubyforge (1.0.3)SystemTimer (1.1.1)term-ansicolor (1.0.3)treetop (1.2.5)uuidtools (1.0.7)
Jason Butler
A: 

I received this error as well. You cant just gem install mysql without pointing it to your mysql_config file like:

sudo gem install mysql -- --with-mysql-config=/path/to/user/local/mysql/bin/mysql_config

I had to install mysql from macports because I didn't have the headers available on my system. I was using MAMP priorly.

Macports installed to /opt so my mysql-config path was /opt/local/bin/mysql_config5

Corban Brook
Thanks. I just rebuilt the gem (on my Ubuntu system, it's /usr/bin/mysql_config). I'm still getting the same error in the apache log.!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
Jason Butler
Have you restarted apache?
Corban Brook
A: 

Is the mysql bin directory in the path of the user running Rails in production?

Sarah Mei
Thanks for the response! I think I have the paths set up correctly. Are they?$ $PATH-bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$ whereis mysqlmysql: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz$ mysql -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 19Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
Jason Butler
Grr. Can't seem to do linebreaks in the comments.
Jason Butler
That looks correct. Sorry it couldn't be an easy fix. :)
Sarah Mei
+7  A: 

Figured it out. Woo Hoo!

Summary: Ruby Enterprise Edition (update, thanks Hongli!) has its own set of gems. Even though I was updating the gem, it wasn't the one that Passenger was reading.

Here's how I figured that out:

>> /usr$ whereis gem

gem: /usr/bin/gem /usr/bin/gem1.8 /opt/ruby-enterprise-1.8.6-20090201/bin/gem

>> /usr$ cd /opt/ruby-enterprise-1.8.6-20090201/bin/

>> /opt/ruby-enterprise-1.8.6-20090201/bin$ ls -l

total 2624
-rwxr-xr-x 1 root root    3907 2009-03-26 14:47 erb
-rwxr-xr-x 1 root root     813 2009-03-26 14:47 gem
-rwxr-xr-x 1 root root     349 2009-03-26 14:47 irb
-rwxr-xr-x 1 root root     386 2009-03-26 14:47 passenger-config
-rwxr-xr-x 1 root root     402 2009-03-26 14:47 passenger-install-apache2-module
-rwxr-xr-x 1 root root     396 2009-03-26 14:47 passenger-make-enterprisey
-rwxr-xr-x 1 root root     392 2009-03-26 14:47 passenger-memory-stats
-rwxr-xr-x 1 root root     392 2009-03-26 14:47 passenger-spawn-server
-rwxr-xr-x 1 root root     386 2009-03-26 14:47 passenger-status
-rwxr-xr-x 1 root root     391 2009-03-26 14:47 passenger-stress-test
-rwxr-xr-x 1 root root     366 2009-03-26 14:47 rackup
-rwxr-xr-x 1 root root     367 2009-03-26 14:47 rails
-rwxr-xr-x 1 root root     364 2009-03-26 14:47 rake
-rwxr-xr-x 1 root root    1560 2009-03-26 14:47 rdoc
-rwxr-xr-x 1 root root      64 2009-03-26 14:46 ree-version
-rwxr-xr-x 1 root root    1516 2009-03-26 14:47 ri
-rwxr-xr-x 1 root root 2609905 2009-03-26 14:46 ruby
-rwxr-xr-x 1 root root     178 2009-03-26 14:47 testrb

>> /opt/ruby-enterprise-1.8.6-20090201/bin$ ./gem list

*** LOCAL GEMS ***

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
fastthread (1.0.5)
passenger (2.1.2)
postgres (0.7.9.2008.01.28)
rack (0.9.1)
rails (2.3.2)
rake (0.8.4)
sqlite3-ruby (1.2.4)

>> /opt/ruby-enterprise-1.8.6-20090201/bin$ ./gem install mysql

Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed

Then, I restarted the instance, and it worked.

Jason Butler
Ahh good job. I dont have passenger setup on enterprise ruby yet so didnt't know this. Im sure you just saved me some time in the future when i eventually upgrade.
Corban Brook
That's had me before too. Such an annoyance!
Mr. Matt
+2  A: 

@Jason Butler: I do not have enough reputation to comment so I'll post it as an answer instead.

It's not Phusion Passenger that has its own set of gems, it's Ruby Enterprise Edition. This is in fact documented, and its reason explained: http://www.rubyenterpriseedition.com/documentation.html#_how_ree_installs_itself_into_the_system

Hongli
Thanks! Good to know. I'm a product manager by trade, so I was doing a bit of voodoo debugging. I hope someone in the future finds this helpful.
Jason Butler