I upgraded to Snow Leopard recently and after having troubles with MySQL I upgraded it as well. I followed these instructions and built MySQL by myself using these sources.
Now MySQL server works fine, but I can't get Mysql2 gem working.
I keep getting this error when starting any Rails3 app:
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): no suitable image found. Did find: (LoadError)
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: mach-o, but wrong architecture - /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
I tried everything, but I'm still getting the same error. Do you have any idea what might be wrong?
Try installing MySQL 64 bit from here
I had the same problem and it worked for me ,
also try using rvm
some version of ruby might not work properly so it's pretty easy to change between them with rvm .
Related
Rails version 6.0.4.6
Ruby Version 2.7.5p203
mySql version 8
OS Window 10
I am having issues getting the mysql2 gem to work. The latest error I have is not being able to locate "mysql2 x64-mingw32" file. I installed the gem using this command:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\Program Files\MySQL\Connector C++ 8.0"
--with_mysql-lib="C:\Program Files\MySQL\Connector C++ 8.0\lib64" --with_mysql_include="C:\Program Files\MySQL\Connector C++ 8.0\include"
It appears to have been installed correctly but still will not work. I have run bundle install. I have also tried deleting the gem.lock file and the running bundle install.
If anyone has had success in getting ruby to work with MySQL on a Windows machine, please let me know how you did it.
After many trails, it appears the Ruby just doesn't play well with Windows OS. While I expect that some do use Ruby on Windows, it appears the support is lacking, and the community is small.
I installed a Linux terminal on my machine and had much better luck.
Just posting to keep other from pulling their hair out.
Im newbie starting to learn ruby/rails. While i was trying to setup WeBRICK to run, an error related to the libmysql.dll appeared, so ive downloaded an dll from an older version of mysql and tried again, but the error kept. Then i read that the problem was that my computer is 64bit and the gem mysql2 installed apparently is 32bit, that way i uninstalled that gem and tried to do the following workaround:
1) download mysql connector 32 bits
2) gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
the problem now is that im getting the following error:
ERROR: While executing gem ... (Errno::EEXIST)
File exists - C:
So, now i cant even install the mysql2 gem
Can you guys help me please?
It's not recommended to run ruby on rails on windows. mac or linux will be better.
if you can't change your OS. you can try this:
http://eric.cloud-mes.com/2012/04/1/install-Ruby-1.9.3-and-Rails-3.2.3-on-Windows-7.html
I'm on Windows, and I have a working Rails 2.3.8 app on Ruby 1.8.6 with MySQL 5.0 and the mysql gem version 2.8.1. It all works.
I just installed Ruby 1.9.1, installed gems for rails(2.3.8) and mysql. BUT NOW when I run ruby script/server:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
I ALREADY INSTALLED IT!
One thing that might be a problem:
When I run "gem list" in my working ruby (v1.8.6) install, it lists "mysql (2.8.1)". BUT when I run "gem list" in the new ruby install (v1.9.1), it lists "mysql (2.8.1 x86-mingw32)". If that's the cause, how do I fix it? If it's not, what on earth is keeping Rails from recognizing the installed mysql gem?
Thanks in advance. I'm sure this is a common upgrade path, so I can't be the only one with this problem...
Finally got some solid info.
Apparently the mysql gem sucks, and shouldn't be relied on going forward.
That's why Rails 3.0.0 officially endorses the mysql2 gem instead (gem install mysql2), which unfortunately is not supported under Windows yet, though the gem's developer seems to be working on it.
As I try to get my app to Rails 3, I'm just going to make the easy switch to sqlite3 until there's a good mysql gem for windows.
I have a rails environment which I set-up with macports. I recently updated macports which seems to have had the side effect of breaking rails. When I try to boot a rails server I get:
$ ./script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
/opt/local/lib/ruby/vendor_ruby/1.8/i686-darwin9/mysql.bundle: dlopen(/opt/local/lib/ruby/vendor_ruby/1.8/i686-darwin9/mysql.bundle, 9): Library not loaded: /opt/local/lib/mysql5/mysql/libmysqlclient.15.dylib (LoadError)
Referenced from: /opt/local/lib/ruby/vendor_ruby/1.8/i686-darwin9/mysql.bundle
Reason: image not found - /opt/local/lib/ruby/vendor_ruby/1.8/i686-darwin9/mysql.bundle
I've tried reinstalling the mysql gem many times using various configurations I've found around the web but nothing seems to help. Also, when I try to use rake I get:
rake db:migrate
Rails requires RubyGems >= 1.3.1 (you have 1.0.1). Pleasegem update --systemand try again.
Even though:
gem --version
1.3.6
What's going on here?
It seems the problem was that I had rails installed under macports, and also as a gem. I uninstalled all the rails components from macports and just stuck with the gems version and it seems to have made the MySQL problem go away.
I had trouble with the gem at first but got it to work when I installed the 64-bit MySQL and reinsatlled the gem with arch flags.
So it work in rails. The error I used to get was
uninitialized constant MysqlCompat::MysqlRes
but that is now gone :)
However in Xcode when I run a RubyCocoa project I still get the old error of
uninitialized constant MysqlCompat::MysqlRes
Does anyone know why this may be?
Is it because the gdb is 64-bit?
How can it work in Rails but not in RubyCocoa?
A little debugging shows that it fails to load mysql_api.bundle
/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle:
dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle, 9): no suitable image found.
Did find: (LoadError) /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle: mach-o, but wrong architecture -
/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
The problem might be that xcode uses another version of the ruby framework than you are using normally, I had that trouble and solved it somehow.
The architecture mismatch might be some other thing though:
/System/Library/Frameworks/Ruby.framework
I had the same problem and it had something to do with an older MySQL installation if I remember correctly. I installed the 32-bit version by accident, noticed the mistake and installed the 64-bit one.
I got rid of the error by removing MySQL as described here: How do you uninstall MySQL from Mac OS X and reinstalling the latest version with arch flags.
Did you try this?