mysql gem for snow leopard - mysql

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?

Related

193: %1 is not a valid Win32 application error with Ruby (1.9.3) on Rails(3.2.3) with MySQL(5.5) on Windows 7

I cannot seem to run a rail application configured to MySQL. When I run the project, I get the following error:
193: %1 is not a valid Win32 application. - C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
I've noticed others have hit this but I didn't find any solutions that worked for me. Here's what I've tried so far:
Copying libmysql.dll to the ruby bin folder
Tried older version of MySQL (5.0)
Checked the ImagePath for MySQL on regedit
Can anyone provide guidance here? Is this just a lost cause? Does using Linux or other versions of Ruby/Rails/MySQL combo fix this?
Looks that you installed the binary pre-compiled version of MySQL gem, which requires an specific version of MySQL to be installed.
More important, it requires an specific version of libmysql.dll be available in the PATH so the gem can use it.
I would recommend you uninstall the pre-compiled gem and proceed with the manual compilation steps described here:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
This has been answered before too:
Ruby Gem for mysql 5.5 in windows
Is Datamapper's dm_mysql_adapter gem supported on windows?
Finally installed MySQL for Rails in Windows 64 bit, and now
on windows Mysql native extension prob in ruby on rails gem time
Hope that helps.

Ruby on rails undefined method `where' for #<Class:0x10377d590>

I am trying to migrate from windows 7 to mac osx .
I have installed the following
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
mysql Ver 14.14 Distrib 5.1.56, for apple-darwin10.3.0 (i386) using
readline 5.1
After a lot of pain I installed my sql gem by :
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
But still when I run my project in netbeans I get the following error
[4;36;1mUser Columns (31.5ms)[0m
[0;1mSHOW FIELDS FROM users[0m
[4;35;1mSQL (1.2ms)[0m [0mSHOW
TABLES[0m /!\ FAILSAFE /!\ Wed May
04 09:53:16 +0530 2011 Status: 500
Internal Server Error undefined
method `where' for
Can anyone tell me what am I doing wrong ?
The database migrations are working perfectly.
You stopped copying the stack trace right at the point where it was about to tell you where the error occurs. Look down the stack trace for the first mention of any code from your app (as opposed to the gems or the vendor folder) and it should point you to the problem line.
It's unfortunate that you've having such a time installing the MySQL gem, but this can be complicated if you're loading it on a from-scratch machine that's missing the development headers, something required to compile the extension, and your path does not include /usr/local/mysql/bin which is common.
You can fix that by creating a file /etc/paths.d/mysql with the following:
/usr/local/mysql/bin
Generally you should just have to list mysql in your Gemfile after that, and it should install conventionally with bundle install.
As for the error, it looks like something deeper in your application that's blowing a gasket. When you say "run your project in netbeans," but do you mean run unit tests? It looks like you're calling where on something that doesn't support it.
This looks like an application error. The server is bailing with a 500 when it fails to evaluate the method 'where', somewhere likely in your code.
Modern Mac operating systems (forget which was the first) come with ruby and rails pre-installed - not sure if this is related to your setup.
What happens when you run
rails server
from the console (from within the directory of the app) ?
where is a ActiveRecord 3 AREL class method used for conditions.
First things first, do you have XCode installed? thats a prerequisite to installing any native gems. You can download XCode 3 from the apple site or buy XCode 4 from the app store.
More of the stack trace is required.
Ideally though, once you have installed XCode, you should take a look at https://rvm.io - it's the preferred way for managing rubies on Unixy systems.
Thanks guys.. I finally found the error was with the authlogic gem
I had installed 3.0.2
and the application requires an older version 2.x

Mysql2 gem problem after upgrading to Snow Leopard

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 .

Rails 3 Mysql rake db:create issue

I've recently upgraded to Rails 3 and am getting the following issue when trying to run rake db:create to create a mysql database of which has been defined in database.yml
Some info about my setup:
running snow leopard
rails gem v3.0.3
mysql gem v2.8.1
mysql 5.5.8
I'm presented with this issue:
$rake db:create
(in /Users/elliottheis/Sites/demoProject)
rake aborted!
uninitialized constant Mysql::Error
(See full trace by running task with --trace)
Does anyone have any ideas how to solve this, it's driving me nuts!
Make sure Mysql is in your Gemfile and the database.yml is setup for Mysql. Uninitialized constant simply and will most likely always mean you have not told Rails where to find it. It you can type mysql -uroot into Terminal and see the Version then you know that MySql is fine. Try post a bit more information and we will see if we cant get to the bottom of this.
rake -r mysql db:create --trace
If this does not work then something has gone wrong in the installation. Try This.
Uninstall Mysql - Follow these instructions
Reinstall Mysql - Follow these instructions
Let us know how you get on and tell us the solution when you get it. All the best
I know this has already been answered, but in case this happens to someone else, my issue was identical to Elliot's.
However, my fix revolved around using mysql gem 2.8 and Snow Leopard, which which is explained in another Stackoverflow thread:
As it turns out, that class should not exist; the error message is
caused by a problem with the latest Mysql driver. mysql-2.8.1 looked
for my libraries in a directory named with an extra level of ‘mysql’
at the end. For instance, my libraries (under MacOS X 10.5.8), are in
/usr/local/mysql/lib, but the mysql.bundle library looks for the MySQL
libraries at /usr/local/mysql/lib/mysql … which is wrong.
So I needed to install the mysql gem version before 2.8. Follow the instructions on this Web site, and your issue should be resolved.

Mysql gem troubles with Snow Leopard upgrade

I have done everything that is on the web (i think)
i have the new 64 bit xcode that came with snow leopard installed
completely removed mysql, removed gems compeltely, removed rails
installed mysql 64 bit, installed gems, installed mysql gem with the env ARCHFLAGS set
I still get this nasty
NameError: uninitialized constant MysqlCompat::MysqlRes
from /Users/Navara/Sites/tuosystems/vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in `load_missing_constant'
from /Users/Navara/Sites/tuosystems/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `rake_original_const_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
Im not sure how to debug this..
any pointers will be greatly appreciated!
the only thing that i did not reinstall was the problem! RUBY! and doing that fixed it!