Kevin Z
Kevin Z

Reputation: 341

MySQL Ruby Gem install issues

So I know that this question has been asked before, and I have looked through all of the previous answers and still can't find a solution. Hoping you all can help.

The setup: I am running Mac OS X 10.6 Server. I have used the built in MySQL install on web apps and it works great. Now I am trying to run a RoR app that requires MySQL.

So, whenever I enter

gem install mysql

it spits back the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/Users/admin/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb --with-mysql-config=/var/mysql
*** 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=/Users/admin/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
    --with-mysql-config
extconf.rb:35:in ``': Permission denied - /var/mysql --cflags (Errno::EACCES)
    from extconf.rb:35:in `<main>'


Gem files will remain installed in /Users/admin/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql-2.8.1 for inspection.
Results logged to /Users/admin/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql-    2.8.1/ext/mysql_api/gem_make.out

So, through my research, I tried to specifically state the location of the MySQL install.

gem install mysql -- --with-mysql-config=/var/mysql

Unfortunately, with the same results.

Any ideas of where to go from here?

Thanks!

Kevin

Upvotes: 3

Views: 8316

Answers (5)

jacr1614
jacr1614

Reputation: 1310

I had success with this sudo gem install mysql -v '2.8.1' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config but specifying the mysql version that I need

Upvotes: 0

Pranay
Pranay

Reputation: 1

gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

Using the above worked with ruby Ruby 2.0 on Windows. I changed the library to just lib instead of lib\opt because lib\opt is not present in MySQL Server 5.5.

I picked the above command from a solution to this problem presented at: http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

Upvotes: 0

nuxxxx
nuxxxx

Reputation: 223

On Mac OSX Lion 10.7 this command helped me install the mysql2 gem:

sudo gem install mysql2 -- --with-mysql-lib=/usr/local/Cellar/mysql55/5.5.30/lib --with-mysql-include=/usr/local/Cellar/mysql55/5.5.30/include/

Before this I did install mysql55 via brew like described above.

Upvotes: 1

Scott Corscadden
Scott Corscadden

Reputation: 2860

Your milage may vary, but here's what seemed to work for us. First, ensure you have the right libraries on there first (from Apple):

http://www.opensource.apple.com/other/MySQL-53.binaries.tar.gz

Install those via:

sudo tar -xvf ~/Downloads/MySQL-53.binaries.tar -C /

Then, for our 10.6 Server, the location of mysql_config was different:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

Upvotes: 0

D. Simpson
D. Simpson

Reputation: 1892

Kevin,

This article may help you address your problem:

http://rapd.wordpress.com/2007/05/17/battle-against-ror-gem-install-mysql/

Upvotes: 5

Related Questions