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.
I have read some webpages that talk about checking whether you have
libmysqlclient installed (without saying how one might check that!)
and moving MySQL from 64-bit to 32-bit installation (again, there is
no indication of how one does this). This is in Mac OS X 10.5.6.
I would really rather not mess about unduly with my MySQL
installation, since I use it for other purposes. So is there a simple
way for me to "downgrade" my Rails installation to one that does play
nicely with MySQL (and which one is that, BTW)?
Thanks,
Ian.
--
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?
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.
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
...
--
Posted via http://www.ruby-forum.com/.
>
> 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.
--
> So, where did you install MySQL and what version of it did you
> install?
>
> -Conrad
/usr/local/mysql - that was the location that the installer chose. I
am currently running MySQL version 5.0.45 on an Intel iMac with Mac OS
X 10.5.6. And I haven't changed anything recently apart from upgrading
from Rails 2.1.0 (where things worked fine) to Rails 2.2.2 (where they
don't).
:-)
Ian.
--
On Mac OS X you can't just simply run sudo gem install mysql. You must
use the instructions that are specific to Mac OS X.
This really has to do with the nature of Mac OS X Leopard and is
somewhat unrelated to Rails or Ruby.
Mac OS X 10.5 (Leopard) builds universal binaries by default. However,
most installations of MySQL on Mac OS 10.5 are Intel only so you must
tell the gcc compiler to build for your specific platform: i386 or ppc.
Here is the command to use to install the mysql gem for Intel:
sudo env ARCHFLAGS="-arch i386" gem install mysql
--with-mysql-config=/usr/local/mysql/bin/mysql_config
Note: That is all one line.
However, you may still have an issue with one of the dynamic libraries.
This is where I had an issue with my install.
Here is the fix:
sudo install_name_tool -change
/usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
/usr/local/mysql/libmysqlclient.15.dylib
/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Note: You may need to confirm the paths in that command, because some of
the blogs I tried didn't have it correct and I'm not sure if this one is
one of those. So make sure the libmysqlclient.15.dylib is actually in
the location specified above. Same goes for the mysql.bundle path.
I didn't say it was required to install MySQL. It is, however, necessary
for installing the mysql gem using RubyGems on Mac OS X Leopard.
Note: It's not required for Mac OS X 10.4 (Tiger).
I didn't say it was required to install MySQL. It is, however, necessary
Conrad Taylor wrote:
> Hi, I have both Intel and G5 Macs and I was able to simply install MySQL
> without
> requiring any architecture flags.
for installing the mysql gem using RubyGems on Mac OS X Leopard.
Note: It's not required for Mac OS X 10.4 (Tiger).
By the way that command for installing the mysql gem I posted was
straight out of the instructions in comments at the top of the
database.yml file for a new Rails 2.2.2 project, which looks something
like:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On Mac OS X:
# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
# On Mac OS X Leopard:
# sudo env ARCHFLAGS="-arch i386" gem install mysql --
--with-mysql-config=/usr/local/mysql/bin/mysql_config
# This sets the ARCHFLAGS environment variable to your native
architecture
I just realized that the command I posted earlier was missing the extra
-- after mysql and before --with-my...
So make sure you use the command exactly as above and it should work
fine. If you happen to have a PowerPC based mac running leopard, be sure
to switch out -i386 with -ppc.
On Mon, Mar 2, 2009 at 8:22 AM, Robert Walker <rails-mai...@andreas-s.net> wrote:
I just realized that the command I posted earlier was missing the extra
Robert Walker wrote:
> # On Mac OS X Leopard:
> # sudo env ARCHFLAGS="-arch i386" gem install mysql --
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> # This sets the ARCHFLAGS environment variable to your native
> architecture
-- after mysql and before --with-my...
So make sure you use the command exactly as above and it should work
fine. If you happen to have a PowerPC based mac running leopard, be sure
to switch out -i386 with -ppc.
OK, sorted. Thanks for all of your help. Here, for the record, is what
I did, based on your collected suggestions:
1. I ran this command (all on one line):
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-
config=/usr/local/mysql/bin/mysql_config
2. I did the install_name_tool thing (also all on one line - note the
paths carefully - the first is the wrong path, the second is the
correct path and the third should also be correct):
sudo install_name_tool -change /usr/local/mysql/lib/mysql/
libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib
3. To test, I created a new mysql project, changed to the project
folder, edited the username and password in config/database.yml and
then typed rake db:create:all. This just returned the command prompt
with no error.
Here is the transcript:
==== transcript ====
frost:rails ian$ sudo env ARCHFLAGS="-arch i386" gem install mysql --
--with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed
frost:rails ian$ sudo install_name_tool -change /usr/local/mysql/lib/
mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.
15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
frost:rails ian$ rails -d mysql dbtest
frost:rails ian$ cd dbtest
frost:dbtest ian$ rake db:create:all
==== transcript ====
Ian.
--