0

I'm having trouble finding good instructions on how to install mysql2-0.2.6 and have it up and running for a ruby on rails application. Could anyone please break down this process?

When I try to install the gem, I get this error:

Installing mysql2 (0.2.6) /Library/Ruby/Site/1.8/rubygems/installer.rb:574:in `initialize': Permission denied - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/.gitignore (Errno::EACCES)
Justin Meltzer
  • 13,318
  • 32
  • 117
  • 182
  • Duplicate of http://stackoverflow.com/questions/5216563/how-do-you-install-mysql2-0-2-6-on-a-mac-and-connect-it-to-your-ruby-on-rails-app which you posted not long ago. You should clarify your original question instead of creating a new one. – Michelle Tilley Mar 07 '11 at 06:49
  • It was closed for some reason, and I think you posted the wrong link. – Justin Meltzer Mar 07 '11 at 06:50
  • `gem "mysql2", '~> 0.2.6'` in gemfile and then `bundle install` – Zabba Mar 07 '11 at 07:00
  • Doesn't work. I get this error: Installing mysql2 (0.2.6) /Library/Ruby/Site/1.8/rubygems/installer.rb:574:in `initialize': Permission denied - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/.gitignore (Errno::EACCES) – Justin Meltzer Mar 07 '11 at 07:06
  • Ideally, you should be using RVM so that you avoid using `sudo gem install ...`. (http://rvm.beginrescueend.com/) – Zabba Mar 07 '11 at 08:02

4 Answers4

0

I think this permission error can be fixed by doing: XCode -> Preferences -> Downloads -> Components tab -> Command Line Tools: press download

Now it should be possible to install through command line. Regards. Íris

user909943
  • 111
  • 6
0

This error is mainly occurred when we install mysql2-0.2.6 with Ruby 1.9.3 version. If you switched to Ruby 2.0, this problem will be solved. Ruby 1.9.3 reached EOL(https://github.com/sstephenson/rbenv/issues/712) and no support has been given by Ruby core team. Hence there is no use to try with Ruby 1.9.3.

maniempire
  • 791
  • 11
  • 12
0

Try

chmod 666 /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/.gitignore
Zach
  • 2,441
  • 1
  • 16
  • 20
  • now i get this error: Installing mysql2 (0.2.6) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1216:in `chmod': Operation not permitted - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/.gitignore (Errno::EPERM) – Justin Meltzer Mar 07 '11 at 07:17
  • What user are you running the commands as? Who owns the file? Can you tell me the output of this command: `ls -l /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/.gitignore` – Zach Mar 07 '11 at 07:20
  • I just get this: `-rw-r--r-- 1 root admin 90 Mar 7 02:21 /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/.gitignore` – Justin Meltzer Mar 07 '11 at 07:25
  • Since the file is owned by root, you need to be root to modify its permissions. If the user running gem is not root and it tries to modify the permissions of the file, it will return the error you are getting. Try sudo'ing the gem install. – Zach Mar 07 '11 at 07:29
0

Locate your path to the mysql_config

locate mysql_config

Using that path install the gem

sudo gem install mysql2 -- –with-mysql-config=/path/to/your/mysql_config

Worked for a bunch of people. Give it a whirl.

EDIT - for missing locate make sure you're in the root and then run sudo /usr/libexec/locate.updatedb

Community
  • 1
  • 1
Eva611
  • 5,964
  • 8
  • 30
  • 38
  • when i run `locate mysql_config` I get this: WARNING: The locate database (/var/db/locate.database) does not exist. To create the database, run the following command: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist – Justin Meltzer Mar 07 '11 at 07:24
  • I ran that command, but I still get the same message when I run `locate mysql_config` – Justin Meltzer Mar 07 '11 at 07:25
  • Ok so now when I follow this there's still an error: ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. – Justin Meltzer Mar 07 '11 at 07:38
  • hmm... here try downloading a fresh copy from http://dev.mysql.com/downloads/mysql/ and then installing the gem – Eva611 Mar 07 '11 at 07:57