Rails + Mysql

Hi... I'm a rails newb, trying to do some rails homework or sort of... I'm trying to run rails on Fedora 12... but it seems impossible... It's impossible to install the mysql gem... this is the last output when I tried to run a rake db:migrate: uninitialized constant MysqlCompat::MysqlRes

Any suggestion?

Hi... I'm a rails newb, trying to do some rails homework or sort of... I'm trying to run rails on Fedora 12... but it seems impossible... It's impossible to install the mysql gem...

Can you show the output for gem install mysql?

this is the last output

It looks like the gem is already installed, but when i run rake db:migrate I got this error of uninitialized constant MysqlCompat::MysqlRes.

this is the output of gem install mysql

#sudo gem install mysql --no-ri --no-rdoc Building native extensions. This could take a while... Successfully installed mysql-2.8.1 1 gem installed

and then I run rake db:migrate and voila...

"uninitialized constant MysqlCompat::MysqlRes"

It looks like the gem is already installed, but when i run rake db:migrate I got this error of uninitialized constant MysqlCompat::MysqlRes.

this is the output of gem install mysql

#sudo gem install mysql --no-ri --no-rdoc Building native extensions. This could take a while... Successfully installed mysql-2.8.1 1 gem installed

and then I run rake db:migrate and voila...

"uninitialized constant MysqlCompat::MysqlRes"

José, did you add the following to your environment.rb file:

config.gem 'mysql'

Good luck,

-Conrad

@Conrad: thanks for take the time... I did what you told me... this it what I change in enviroments.rb

config.gem "mysql-ruby",:lib=>"mysql"

Then, run again rake db:migrate and got this output:

"Missing these required gems:   mysql-ruby

You're running:   ruby 1.8.6.383 at /usr/bin/ruby   rubygems 1.3.6 at /home/user/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8 Run `rake gems:install` to install the missing gems."

run rake gems:install and got this output:

"gem install mysql-ruby ERROR: could not find gem mysql-ruby locally or in a repository"

I got to say that this is a royal pain in the ass... I am a postgres guy, but I wanted to try with mysql, and this is painfull... I don't know if this is a test for newbies or something like that...

Any sugestion?

Thanks

@Conrad: thanks for take the time... I did what you told me... this it what I change in enviroments.rb

config.gem "mysql-ruby",:lib=>"mysql"

Then, run again rake db:migrate and got this output:

"Missing these required gems: mysql-ruby

You're running: ruby 1.8.6.383 at /usr/bin/ruby rubygems 1.3.6 at /home/user/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8 Run `rake gems:install` to install the missing gems."

run rake gems:install and got this output:

"gem install mysql-ruby ERROR: could not find gem mysql-ruby locally or in a repository"

I got to say that this is a royal pain in the ass... I am a postgres guy, but I wanted to try with mysql, and this is painfull... I don't know if this is a test for newbies or something like that...

Any sugestion?

José, try installing the MySQL gem by doing the following:

sudo gem install mysql

or

gem install mysql

Then update the config.gem line to

config.gem "mysql"

Good luck,

-Conrad

Done! Same results...

uninitialized constant MysqlCompat::MysqlRes

Thanks... Any other approach?

José, can you verify that MySQL is running by doing the following:

$ mysql -u<username>

-Conrad

Yes it's running...

Jose, What rails version and mysql version are you using? Do this: rails -v mysql --version

I have the same issue as your after I upgraded to rails 2.2.2 and finally, I got it work What I did, I reinstall mysql and it worked ok now.

Yudi Soesanto

*mysql --version mysql Ver 14.14 Distrib 5.1.44, for redhat-linux-gnu (i386) using readline 5.1

*rails -v Rails 2.3.5

Jose,

Uninstall gem mysql first (sudo gem uninstall mysql) and then install it again with this command:

$ sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

for reference:

Check on this link http://wiki.rubyonrails.org/database-support/mysql, maybe it can help.

If it still doesn’t work, try to reinstall mysql server.

Good luck,

Yudi Soesanto

I'm having the same "uninitialized constant MysqlCompat::MysqlRes" problem. Here is my configuration:

OS X 10.6.2 Rails 2.3.5 5.5.0-m2 MySQL Community Server ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10.2.0]

-Rahil

José Luis Romero wrote:

Done! Same results...

uninitialized constant MysqlCompat::MysqlRes

Thanks... Any other approach?

Try setting ARCHflags.

OSX Snow Leopard will return the same results you're getting if you don't set the ARCHflags. You'll have to look them up for your system, but the syntax is something like this:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

When you get the ARCHflags parameter right, that should resolve your uninitialized constant issue.

If you then get the "No definition for [ResourceName]" ri and RDoc warnings/errors, first uninstall your gem again, and then you'll have to do something like this:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

http://forums.mysql.com/read.php?116,359591,359591#msg-359591

That may or may not be enough to get the mysql gem working in your environment. I'm still tracing out problems.

Regards,

mike