Get Rails running on fresh Ubuntu install
I created a VM running the latest Ubuntu because it was causing so many problems on my Windows machine.
I got RVM installed, have versions 1.8.7 and 1.9.2 setup with 1.9.2 as the default. I installed gems, installed Rails.
If I try to do anything with Rails (generate, server, etc.) I get this error:
You have requested: mysql2 ~> 0.2.6
The bundle currently has mysql2 locked at 0.2.6. Try running
bundle update mysql2
First problem, my rails app isn't even using mysql. It's using SQLite.
Anyway, I runbundle update mysql2
like it says...and I get a bunch of errors. The start of them is this:
Installing mysql2 (0.2.6) with native extensions /home/jamesw/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/instal开发者_如何学编程ler.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/home/jamesw/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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.
I am not good with server setup and things like this. I am an OS X user, but didn't have to deal with any of this on OS X. Can anyone point me in the right direction?
If you want to get rid of the MySQL dependency, check your Gemfile, which is probably where it's being required.
If you're curious, the reason why the mysql gem compilation is failing is because you probably don't have the mysql client header files installed. For Ubuntu, I believe "apt-get install libmysqlclient-dev" would take care of it. You would also need the "build-essential" package installed. But all that's academic if you remove MySQL from your Gemfile.
Look in the Gemfile and see if there is a line that looks like either of the following.
gem "mysql2"
gem "mysql2", 0.2.6
If there are, comment out or delete these lines, remove Gemfile.lock and run bundle install again.
精彩评论