Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

Hi there,
I just started using aptana and am working on my HelloWorld, but I'm
gettin the same error "uninitialized constant MysqlCompat::MysqlRes".
Did you ever figure out what is it about?
Thanks!
On Jul 31, 12:00 pm, "Martin J." <rails-mailing-l...@andreas-s.net>

Martin J. wrote:
> Hi,> I installed the "kwatch-mysql-ruby" gem on my Debian server but when I> try to run the "db:migrate" task I get the following error:>> ** Invoke db:migrate (first_time)> ** Invoke environment (first_time)> ** Execute environment> ** Execute db:migrate> rake aborted!> uninitialized constant MysqlCompat::MysqlRes
I saw this, having freshly installed Rails 2.3.3, and then being told to
run 'gem install mysql' because the MySQL client is no longer bundled
with Rails, as of 2.2
Okay, I did that. Then I got the error message you showed in your post
-- about MysqlCompat::MysqlRes not being defined.
Turns out there is no such thing; this error is caused by a malfunction
of the mysql-2.8.1 gem.
If you install the gem by hand, chances are when you run the test you'll
find that the gem's bundle doesn't actually manage to load the
mysqlclient library. (On my MacOS X 10.5.8 system, it's a .dylib; under
Linux it may be a .so)
The error message I saw during the test phase looked like this:
./mysql.bundle: dlopen(./mysql.bundle, 9): Library not loaded:
/usr/local/mysql/lib/mysql/libmysqlclient.15.dylib (LoadError)
Referenced from:
/Users/ccullen/Projects/npapp-v2/mysql-ruby-2.8.1/mysql.bundle
Reason: image not found - ./mysql.bundle
from test.rb:5
From that message you can see it's looking for the mysqlclient library
in a directory one level too deep, vis-a-vis the location my libraries
occupy:
/usr/local/mysql/lib is right; /usr/local/mysql/lib/mysql is not.
It is however pretty simple to create a 'mysql' symlink inside
/usr/local/mysql/lib and point it at '.', allowing the broken
mysql.bundle to locate its libraries.
This is definitely a hack. I just wanted to help, since I haven't seen
any answers posted, and certainly nothing to explain why this error is
occurring.
Best of luck!

I also built the gem with the archflags, but am still getting this
error. Did anyone find a different reason that might be causing this?
On Sep 19, 11:15 pm, Evan Green <rails-mailing-l...@andreas-s.net>

Anybody still has the issue?
I have been using jruby for a while but today I was trying to setup
using the last version of ruby 1.9 and rails 2.3.4 and I got hit with
that.
Also running centos and tried the ARCHFLAGS trick with no success.
Pishty Ags wrote:
> Evan Green wrote:>> This didn't seem to fix the error for me. I still get 'uninitialized>> constant MysqlCompat::MysqlRes'>>>>>> Kyle Fox wrote:>>> To fix this, specify ARCHFLAGS when you install the 'mysql' gem:>>>>>> sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql->>> config=/usr/local/mysql/bin/mysql_config>>>>>> On Aug 27, 12:07ï¿½pm, Caleb Cullen <rails-mailing-l...@andreas-s.net>>>>>>> cheers,>> on my Centos Machine, i had to install mysql-devel.x86_64 first, then i> ran the command:>> env ARCHFLAGS="-arch x86_64" gem install mysql --> --with-mysql-config=/usr/lib64/mysql/mysql_config>> which did the trick.>> thanks Kyle

Actually, doing more research and an strace on the process I found the
problem.
Looking in the wrong place for the location of the library, I added my
mysql lib directory to ld.so.conf/mysql.conf config file and it fixed
it.
Jean Bombeur wrote:
> Anybody still has the issue?>> I have been using jruby for a while but today I was trying to setup> using the last version of ruby 1.9 and rails 2.3.4 and I got hit with> that.>> Also running centos and tried the ARCHFLAGS trick with no success.>>> Pishty Ags wrote:>> Evan Green wrote:>>> This didn't seem to fix the error for me. I still get 'uninitialized>>> constant MysqlCompat::MysqlRes'>>>>>>>>> Kyle Fox wrote:>>>> To fix this, specify ARCHFLAGS when you install the 'mysql' gem:>>>>>>>> sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql->>>> config=/usr/local/mysql/bin/mysql_config>>>>>>>> On Aug 27, 12:07ï¿½pm, Caleb Cullen <rails-mailing-l...@andreas-s.net>>>>>>>>>> cheers,>>>> on my Centos Machine, i had to install mysql-devel.x86_64 first, then i>> ran the command:>>>> env ARCHFLAGS="-arch x86_64" gem install mysql -->> --with-mysql-config=/usr/lib64/mysql/mysql_config>>>> which did the trick.>>>> thanks Kyle

I was having the same problem on Snow Leopard and, after some time I
did the following:
Removed all mysql gems I had:
gem uninstall mysql
In my case I had to specify both mysql-dir and mysql-config (and -arch
x86_64 to 64 bits)
export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --
no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/
local/mysql/bin/mysql_config
Hope it works

Raphael Petegrosso wrote:
> I was having the same problem on Snow Leopard and, after some time I> did the following:>> Removed all mysql gems I had:>> gem uninstall mysql>> In my case I had to specify both mysql-dir and mysql-config (and -arch> x86_64 to 64 bits)>> export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --> no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/> local/mysql/bin/mysql_config>> Hope it works
I was able to resolve this issue. Thanks for your valuable suggestions.
Along with the above steps, I had to configure the LD_LIBRARY_PATH.

These instructions also worked for me after upgrading to Snow Leopard.
In my case mysql was in /opt/local/lib/mysql5, so the following fixed it
for me:
sudo gem uninstall mysql
export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc
--no-ri mysql -- --with-mysql-dir=/opt/local/lib/mysql5
--with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
> I was having the same problem on Snow Leopard and, after some time I> did the following:>> Removed all mysql gems I had:>> gem uninstall mysql>> In my case I had to specify both mysql-dir and mysql-config (and -arch> x86_64 to 64 bits)>> export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --> no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/> local/mysql/bin/mysql_config>> Hope it works

Andrew McDonough wrote:
> These instructions also worked for me after upgrading to Snow Leopard.> In my case mysql was in /opt/local/lib/mysql5, so the following fixed it> for me:>> sudo gem uninstall mysql>> export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc> --no-ri mysql -- --with-mysql-dir=/opt/local/lib/mysql5> --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
I was able to get the mysql gem to compile by doing something like that;
but then I found that, for whatever reason, /tmp/mysql.sock did not
exist (and so my rake tasks failed, etc). I followed instructions on
the Rails blog to install MySQL from a DMG, and then /tmp/mysql.sock
existed as expected.
HTH.

If you are still getting this issue, I have posted an EXPLANATION as
well as how to derive the correct solution for your system here
http://techliberty.blogspot.com/ the EXPLANATION was to long for a forum
post :)

Steven Hampton wrote:
> If you are still getting this issue, I have posted an EXPLANATION as> well as how to derive the correct solution for your system here> http://techliberty.blogspot.com/ the EXPLANATION was to long for a forum> post :)
Thanks a lot Steven. I am not seeing this issue now, but will definitely
go through your explanation..!!!

Caleb
Could I ask what test you were running during the "test phase" you
mention below?
I'm really stumped by my problems with this bug, and am trying to
determine if my error has the same cause.
thanks,
Rick
Caleb Cullen wrote:
> Martin J. wrote:>> Hi,>> I installed the "kwatch-mysql-ruby" gem on my Debian server but when I>> try to run the "db:migrate" task I get the following error:>>>> ** Invoke db:migrate (first_time)>> ** Invoke environment (first_time)>> ** Execute environment>> ** Execute db:migrate>> rake aborted!>> uninitialized constant MysqlCompat::MysqlRes>> I saw this, having freshly installed Rails 2.3.3, and then being told to> run 'gem install mysql' because the MySQL client is no longer bundled> with Rails, as of 2.2>> Okay, I did that. Then I got the error message you showed in your post> -- about MysqlCompat::MysqlRes not being defined.>> Turns out there is no such thing; this error is caused by a malfunction> of the mysql-2.8.1 gem.>> If you install the gem by hand, chances are when you run the test you'll> find that the gem's bundle doesn't actually manage to load the> mysqlclient library. (On my MacOS X 10.5.8 system, it's a .dylib; under> Linux it may be a .so)>> The error message I saw during the test phase looked like this:>> ./mysql.bundle: dlopen(./mysql.bundle, 9): Library not loaded:> /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib (LoadError)> Referenced from:> /Users/ccullen/Projects/npapp-v2/mysql-ruby-2.8.1/mysql.bundle> Reason: image not found - ./mysql.bundle> from test.rb:5>> From that message you can see it's looking for the mysqlclient library> in a directory one level too deep, vis-a-vis the location my libraries> occupy:> /usr/local/mysql/lib is right; /usr/local/mysql/lib/mysql is not.>> It is however pretty simple to create a 'mysql' symlink inside> /usr/local/mysql/lib and point it at '.', allowing the broken> mysql.bundle to locate its libraries.>> This is definitely a hack. I just wanted to help, since I haven't seen> any answers posted, and certainly nothing to explain why this error is> occurring.>> Best of luck!

For all you folks who couldn't get this to work on Snow Leopard inspite
of trying the ridiculously simple solution(s) mentioned above,
Try this:
Re compile ruby. Then do
sudo env ARCHFLAGS="-arch x86_64" gem install mysql --
--with-mysql-config=/usr/local/mysql/bin/mysql_config
This will ensure that the *right* arch of ruby is used to compile the
native extensions.

Nikhil Gupte wrote:
> For all you folks who couldn't get this to work on Snow Leopard inspite> of trying the ridiculously simple solution(s) mentioned above,>> Try this:> Re compile ruby. Then do>> sudo env ARCHFLAGS="-arch x86_64" gem install mysql --> --with-mysql-config=/usr/local/mysql/bin/mysql_config>> This will ensure that the *right* arch of ruby is used to compile the> native extensions.
and how do you recompile Ruby...
New to the OSX platform...
Thanks.

On Sun, Mar 21, 2010 at 5:45 PM, Mike Montagne <lists@ruby-forum.com>
wrote:
> iMacMike:pfmpe mikemontagne$ rake db:migrate --trace> Unknown database 'pfmpe_development'> database.yml indicates that this is supposed to be the development> database. But no such file exists in my project directory.
What file would you expect? This refers to a database, physical
location dependent on your MySQL configuration.
> Is this a MySQL server configuration issue? Does anybody understand why> this table is not being created?
Perhaps you left out the step where you create it? At least I didn't see
it in your post. You can create databases manually through the MySQL
CLI console or a number of other tools, or you can run the appropriate
rake task. `rake -T` will give you a list of the available tasks.
But you *do* have to create it before running your migrations :-)
HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

Jatin kumar wrote:
> I am not sure of why this error is coming, but just for a moment, try> rake> db:create before doing rake db:migrate.> It might solve your problem.
The Mysql::Result constant is defined in the mysql_api gem (.so shared
object) - this is located in
gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.so
To fix the error the cleanest way I could think of - I created a
symbolic link to this object in /usr/lib/ruby/1.9.1/ - which is in
Ruby's $LOAD_PATH variable - which you can see your own version via :
irb; puts "#{$LOAD_PATH}";
- None of the solutions people had posted on the web helped me - the
main ones I kept seeing were - reinstall the mysql gem with ARCH_FLAGS
set differently - and make a symbolic link mysql -> '.' because Ruby was
looking one directory too deep
I'm using Ubuntu Karamic Koala, Ruby 1.9.1, mysql-2.8.1, rails-2.3.5

Using Mac OS X 10.6.4, the solutions above didn't work for me. I
removed the gem, then tried:
gem install ruby-mysql
instead of the various attempts to get "gem install mysql" to work.
At a glance, this appears to have worked, and my ruby on rails is able
to access database.

Thanks Na Na, I was able to fix the issue by uninstalling the mysql gem
and then installing ruby-mysql gem.
Na Na wrote:
> Using Mac OS X 10.6.4, the solutions above didn't work for me. I> removed the gem, then tried:> gem install ruby-mysql>> instead of the various attempts to get "gem install mysql" to work.>> At a glance, this appears to have worked, and my ruby on rails is able> to access database.

Oren Golan wrote in post #923611:
> I had this issue after upgrading from ubuntu 9.10 (karmic) to 10.4> (lucid).> the solution was to libmysqlclient16-dev:>> sudo aptitude install libmysqlclient16-dev
As a Ubuntu user that did the trick for me.
Thanks a lot, Oren! Your decision to post this probably saved hours of
work for me.

Raphael Petegrosso wrote in post #859937:
> I was having the same problem on Snow Leopard and, after some time I> did the following:>> Removed all mysql gems I had:>> gem uninstall mysql>> In my case I had to specify both mysql-dir and mysql-config (and -arch> x86_64 to 64 bits)>> export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --> no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/> local/mysql/bin/mysql_config>> Hope it works
I tried this and got the following message (also using Snow Leopard)
ERROR: While executing gem ... (Gem::CommandLineError)
Please specify at least one gem name (e.g. gem build GEMNAME)

After wrestling with this problem for several days I finally got it
nailed. 2 things that I have done that made it work:
1. sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri
mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
2. export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
I'm on Snow Leopard, and have only 1 MySQL (x86_64) 5.5, and 1 ruby
(prepackaged with Snow Leopard) installed.

If you have tried all the above and it still didn't work, try the
instructions on THIS page:
http://lightyearsoftware.com/2011/02/mysql-5-5-on-...
It worked for me! (Don't forget to use the "source" command or restart
your terminal session after modifying your bash profile.)