1
votes

I'm getting this error when running the development environment through RubyMine 3.1. The mysql gem is attached, it's running off of Bundler.

Gemfile

gem "mysql",         "2.8.1"

Gem was installed using:

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

via Bundler config.

=> Booting WEBrick
=> Rails 2.3.10 application starting on http://0.0.0.0:3000 [2011-03-21
13:36:43] INFO WEBrick 1.3.1
[2011-03-21 13:36:43] INFO ruby 1.8.7
(2011-02-18) [i686-darwin10.7.1]
[2011-03-21 13:36:43] INFO
WEBrick::HTTPServer#start: pid=625
port=3000
=> Call with -d to detach
=> Ctrl-C to shutdown server /!\ FAILSAFE /!\ Mon Mar 21 13:36:46
-1000 2011 Status: 500 Internal Server Error uninitialized constant
MysqlCompat::MysqlRes

System is using RVM, gemset and ruby 1.8.7, rails 2.3.10, and mysql 5.5.10

I can run the Rails console and server fine through Terminal via

ruby script/server
ruby script/console

Problem seems to be isolated to just trying to run the Rails console and server through RubyMine. There's likely some small configuration setting that I'm missing and haven't seen.

RubyMine is configured to use the ruby and gemset from RVM and it's set to ignore the global gemset as well.

Most solutions I've seen state to downgrade to mysql 5.1, but that doesn't seem to be the real solution as I can run the Rails console and server perfectly fine from the Terminal.

2
I've gone ahead and set the PATH for RubyMine via: devnet.jetbrains.net/docs/DOC-1160 and that's not resolving the issue.John Wang

2 Answers

3
votes

I've spoke with John Wang and he told me but was going on with this issue.

RubyMine is a GUI, so it doesn't pick up the env settings defined for the terminal in the OS X. See this Jetbrains doc to understand better how this works: http://devnet.jetbrains.net/docs/DOC-1160

The link to the tool that it's used to change the Enviroment Variables is wrong on the link above. I've used the following: http://www.epikentros.net/Main/Mac_Software.html

You need to make sure that you have setting on both the Terminal (~/.profile or ~/.bash_profile) and the OS X GUI (using the tool provided in the link above) for DYLD_LIBRARY_PATH (needs to have the mysql lib directory defined here) and PATH (copy the values already defined for the terminal to the OS X GUI)

This should make the trick. If you have any additional problem, check that you are using the same Architecture for the MySQL and the MySQL Gem (i386 or x86_64)

1
votes

Just been having a very similar problem:

  • OSX Leopard
  • MySQL 5.1
  • Rails 2.3.11

script/console and script/server worked OK, but my specs were erroring with

uninitialized constant MysqlCompat::MysqlRes

The solution seems to be to use mysql2 instead of mysql. Don't forget to change the connection adaptor in database.yml