Ian Piper wrote:
Hi all,
I hope someone can inform me on this. I was shocked to find that since
upgrading to Rails 2.2.2 my Rails projects using MySQL have broken.
Can you define "broken?" Are you getting errors? If so what are they?
What version of mysql do you have installed? I'm guessing it was working
just before you upgraded to Rails 2.2.2, but was there anything else
that you upgraded in the process? What version of Rails were you running
before you upgraded to Rails 2.2.2? Did you install a new mysql gem for
instance do you you have it installed at all?
Yes, of course - I should have done that initially but I didn't want to clutter the posting. See below.
I suppose what gets me irritated about this is that I had no prior knowledge that upgrading Rails was going to disable what is probably the most commonly-used database setup for Rails. Presumably there was a good reason to remove the bundled MySQL driver, but I don't know what it is. I haven't changed anything else on my system (apart from Mac OS X updates) since I installed the machine nearly two years ago.
Is there a page somewhere (I looked but couldn't find one) that sets out the potentially adverse implications of upgrading to a particular version of Rails? Seems like it would be a help.
Anyway, back to the error:
I can create a new Rails project using rails -d mysql myproject with no problem, but when I run rake db:create:all I see this error message:
========= message ========
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql
========= message ========
Then when I run sudo gem install mysql I see this:
========= message ========
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
========= message ========
I had issues with mysql, but it didn't take much Googling to find a fix.
So I know for certain that Rails 2.2.2 will work just fine with MySQL,
as long as you have everything setup correctly. Chances are that if
you're having trouble then others have had it already and posted the fix
on their blog.
Well, yes, but like I said, the explanation is not that clear. For example, I don't know how to check whether libmysqlclient is installed. Or how to swap from 64-bit MySQL to 32-bit MySQL.
If you really do end up needing to downgrade, then I would assume
uninstalling the Rails 2.2.2 gems should do the trick.
[sudo] gem uninstall rails --version 2.2.2
[sudo] gem uninstall actionmailer --version 2.2.2
[sudo] gem uninstall actionpack --version 2.2.2
I may have to try that if I can't fix the current broken state. As an alternative, I suppose I could specify an earlier Rails version in my environment.rb file.
Thanks,
Ian.