How do I install mysql gem using bundler? (OS X Lion) - mysql

So, I currently have to do this to install the mysql gem:
export ARCHFLAGS="-arch x86_64" ; sudo gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config
now, in bundler, I'd do something like
gem "mysql", "2.7"
which gives the error:
uninitialized constant MysqlCompat::MysqlRes
because the mysql gem isn't built right.
EDIT: oh, I'm also using RVM.
What I i'm going to try, is re-install the mysql gem normally (the long command), and try copying it into the rvm directory.
I'm on OS X Lion

use
gem install mysql2 -v 0.2.6
instead of
gem "mysql", "2.7"

I had the same issue.
I fixed the problem (kinda) by not using a gemset.
So, all my gems for this project are in the main ruby 1.8.7 environment inside ~/.rvm/.
=\
So.. that's one way to do it.

Related

MySQL gem on OSX 10.7 Lion

Did anyone got the MySQL gem 2.8.1. working on OSX 10.7 ?
I've installed MySQL 5.5.13 64bit and tried the following after the successful installation of MySQL:
env ARCHFLAGS="-arch x86_64" gem install mysql -v='2.8.1' -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
When running a rake command - let's say rake db:migrate - I get this:
uninitialized constant MysqlCompat::MysqlRes
Any idea how to fix that?
I had been struggling with this issue. The two above pointers worked. Here is what I did:
Added to .zshrc or your .bash_profile:
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
Executed this:
env ARCHFLAGS="-arch x86_64" sudo gem install mysql -v='2.8.1' -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
Try adding this to your ~/.bash_profile:
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
Downgrading to MySQL 5.1 is probably the easiest route, if possible.

MySQL gem in OS X Snow Leopard with RVM and REE 1.8.7 never builds correctly

Problem Solved:
The MySQL 2.8.1 Gem does not play well with MySQL 5.5.x
The solution was to uninstall MySQL (using instructions available here). And then install MySQL 5.1.56 using the x86_64 installer from MySQL.com
I reset my .rvm folder permissions as suggested below and then installed the MySQL gem according to the instructions at RVM's site.
Success!
Original Question:
I am running:
OSX 10.6.7 on a Core2Duo 64Bit Macbook Air
RVM 1.6.5
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03 / Mach-O 64-bit executable x86_64 (This Ruby version is set as --default)
MySQL 5.5.11 / Mach-O 64-bit executable x86_64 (Installed using MySQL.com DMG installer)
I've attempted to install the MySQL gem using every command on the net. Running rake db:migrate yields the error uninitialized constant MysqlCompat::MysqlRes
The following install commands all result with uninitialized constant MysqlCompat::MysqlRes
rvmsudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo env ARCHFLAGS="-arch x86_64" rvmsudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo env ARCHFLAGS="-arch x86_64" rvmsudo gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
And these commands don't even install. I just receive this error: Permission denied - /Users/Jake/.rvm/gems/ree-1.8.7-2011.03/gems/mysql-2.8.1/COPYING
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
I have also placed rvm_archflags="-arch x86_64" in ~/.rvmrc. It had no effect.
I have imploded RVM and started from scratch twice. I've uninstalled and re-installed MySQL as well.
What am I doing wrong? What else can I try? Thank you for your help!
Rule #1, when working with RVM. Do NOT use sudo.
DO NOT use sudo...
to work with RVM gems. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening. (You will start to think that someone has a voodoo doll of your application...)
Your permissions are all screwed up because you used sudo, so, you have to fix that:
sudo chown -R Jake ~/.rvm
should restore ownership of all the files to you.
Following that, follow the directions on the RVM site for dealing with MySQL. Do NOT follow directions all over the internet, because nobody knows better than the author of RVM when it comes to making things work with it.
try this
cd `rvm gemdir`
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
In the future, you may want to try using Homebrew to install mysql. Here are some full-proof installation steps that I've run many times on OS X:
http://michaelfarmer.info/preferred-rails-3-and-mysql-installation-on-o

Rails-MySQL Error - uninitialized constant MysqlCompat::MysqlRes

Trying to get a Rails app running on Snow Leopard.
Downloaded mysql-5.5.8-osx10.6-x86_64.dmg and ran installer
Ruby 1.8.7 (Default OS X version)
Rails 2.3.5
When I attempt to run "rake db:migrate" I get
rake aborted!
uninitialized constant MysqlCompat::MysqlRes
Yes I know this has been asked before. I have already reviewed the following links and followed the steps included in them and the result is the same each time.
Rails, MySQL and Snow Leopard
http://techliberty.blogspot.com/2009/12/dealing-with-rake-aborted-uninitialized.html
http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/
Prior to the following commands I run "sudo gem uninstall mysql" followed by "sudo gem clean mysql" based on the above links:
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
It is still failing. I am just flumoxed and would greatly appreciate any help.
Many thanks!
Not had the experience myself and I'm using Snow Leopard, RVM and rails 2.3.5 to 3.0.3, but found another view which deals with the uninstall and reinstall via :
export ARCHFLAGS="-arch i386 -arch x86_64" ;sudo gem install --no-rdoc --no-ri -v=2.7 mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
For more details see the posting at: http://accidentaltechnologist.com/apple/fixing-uninitialized-constant-mysqlcompatmysqlres-error-on-snow-leopard/
For El Capitan you don't need to uninstall / install.
Just found your libmysqlclient.18.dylib file. Location will depent on how you installed mysql
locate libmysqlclient.18.dylib
Once you have the path create a symb link as:
ln -s /usr/local/mysql-5.5.20-osx10.6-x86_64/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
You have two change first param according to your dynamic library location (use the first command).
On El Capitan the link should be to /usr/local/lib. On previous versions link was to /usr/lib/

gem install mysql failure in Snow Leopard

I successfully installed MySql x86_64 in Snow Leopard and Ruby and Ruby Gems seems to be installed properly:
$ which mysql
/usr/local/mysql/bin/mysql
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem
$ mysql
Your MySQL connection id is 404
Server version: 5.1.37 MySQL Community Server (GPL)
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.5
Unfortunatly I get an error installing mysql gem:
$ sudo gem update --system
...
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
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 --with-mysql-config=/usr/local/mysql/bin/mysql_config
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
I think you should try to uninstall the old mysql gem first before recompiling
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Installing the Xcode that's bundled with the Snow Leopard fixed the problem.
For me, it was adding the UNIX Tools option (if I recalled the name accurately), which include the headers. When I installed XCode originally, I didn't include this component because I didn't think that I would be writing UNIX code. Little did I know...
If you've installed MySQL 5 using MacPorts, then use the command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
I had this problem when I updated to Lion. In this case, I when to the app store and downloaded the latest Xcode. Then I uninstalled and reinstalled the database.
The issue had to do with a broken link during the update. Ruby likes to be in /System while Apple places ruby in /Developer.
was stuck with same problem:
Tried most of the solution's: At the end
Edit the app/config/database.yml, change the adapter to mysql2
production:
adapter: mysql2
database: commissi_production
username: root
password: root
host: localhost
& run on terminal
gem install activerecord-mysql2-adapter
Solved the problem.

gem install mysql problem in rails

Im getting an error with a rails app.
The bundled mysql.rb driver has been
removed from Rails 2.2. Please install
the mysql gem and try again: gem
install mysql.
And when i try to do gem install mysql it still doesnt work and im getting this error.
WARNING: Installing to ~/.gem since
/Library/Ruby/Gems/1.8 and /usr/bin
aren't both writable. WARNING: You
don't have
/Users/bartligthart/.gem/ruby/1.8/bin
in your PATH, gem executables will
not run.
I also tried this but it didn't work
sudo gem install mysql −− −−with−mysql−config≡/usr/local/mysql/bin/mysql_config
what could i do to install mysql?
you need to install this first:
apt-get install libmysqlclient-dev
Did you install the MySQL db server? If so, does this file actually exist?:
/usr/local/mysql/bin/mysql_config
If mysql isn't installed, install that first. Then make sure that the mysql_config script you point to is actually there.
What worked for me is adding this to ~/.bash_profile:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
After installing the MySQL gem like this (64 bit version on an Intel osx 10.6):
export ARCHFLAGS="-arch x86_64" ; sudo gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config
Try
sudo gem update --include-dependencies
sudo gem install mysql
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby
This article helped me at the time:
http://craiccomputing.blogspot.com/2008/11/installing-rails-22-on-mac-os-x-mysql.html
To fix that, add "gem: --no-user-install" in your ~/.gemrc file
via