0

I'm using Ruby on rails (RubyMine) and I try starting my project. Which tells me the error "Could not find gem 'mysql2 (~> 0.2.6, runtime)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)".

I've done sudo gem install mysql which gives me

"Error installing mysql: ERROR: Failed to build gem native extension. Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out "

What should I do?

knut
  • 27,320
  • 6
  • 84
  • 112
Michael
  • 644
  • 5
  • 14
  • 33
  • You're probably missing a dependency to build mysql. Open `/var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out` and see what failed. – Joseph Yaduvanshi Aug 08 '11 at 15:43
  • 1
    look at this http://stackoverflow.com/questions/43778/sqlite3-ruby-gem-failed-to-build-gem-native-extension – Sergey Aug 08 '11 at 15:43

2 Answers2

1

You're probably missing the development headers for MySQL. Often this is shipped as an optional package to install. You may need to install mysql-dev or mysql-devel depending on your package manager.

You might also be missing a compiler, so check that you have the required dependencies for gem such as make and gcc.

tadman
  • 208,517
  • 23
  • 234
  • 262
  • 3
    You probably need to install a bunch of things with `apt-get` then, starting with `gcc`. If you use the graphical installer, you'll need to add the "Development Tools". This might get you one step closer: `apt-get install libmysqlclient-dev` – tadman Aug 08 '11 at 16:28
  • Thank you, @tadman. Your comment worked for me on Ubuntu 11.10. – Ryan Edwards Feb 22 '12 at 19:14
0

You might be missing the Ruby development headers as well. On my Ubuntu 11.04 box I have the following aptitude package which is needed for native gem compilation:

ruby1.9.1-dev

Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68