Failing to install activerecord

I am trying to follow the basic "Create a blog in 20 minutes" Rails screencast but have hit a stumbling block already.

When I try to rake db:migrate I get errors about the gem activerecord-jdbcmysql-adapter not being installed. When I try to install it, I am told it doesn't exist.

If I try to simply gem install mysql I get all sorts of madness appearing.

I am running this on Mac OS X 10.6.2 and my installation was all done through gem. My basic setup works (Hello world!).

Here is the error log:

$ rake db:migrate (in /Users/xxxx/Sites/blog) rake aborted!

Please install the jdbcmysql adapter:

gem install activerecord-jdbcmysql-adapter (no such file to load -- active_record/connection_adapters/jdbcmysql_adapter)

(See full trace by running task with --trace)

$ sudo gem install activerecord-jdbcmysql-adapter

ERROR: could not find gem activerecord-jdbcmysql-adapter locally or in a repository

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

/opt/local/bin/ruby extconf.rb
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... no
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.

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=/opt/local/bin/ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir --without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib --with-mlib
--without-mlib --with-mysqlclientlib
--without-mysqlclientlib --with-zlib
--without-zlib --with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib --without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib --without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib --without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib

Gem files will remain installed in
/opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1
for inspection. Results logged to
/opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out


Looks like somehow or other I had two versions of rails installed. I originally did:

gem install rails

which installed 2.3.5. Then when I tried to run scaffolding it said I had the wrong version it complained and suggested I installed 2.3.5...

I did this with the command:

gem install -v=2.3.5 rails

This meant I had two (I found that out when I tried to uninstall), and for some reason it was trying to use the Ruby version... That may have been down to Netbeans using the wrong settings too.

In the end I uninstalled everything, ran:

gem install -v=2.3.5 rails

and made sure Netbeans was not trying to use JRuby as it was before. Now I have one version that doesn't complain for scaffolding or db:migrate. Sold!


It sounds like you don't have the Apple Dev Tools installed, which includes the Ruby header files.

That's what fixed it when I was running into this ERROR: Failed to build gem native extension.


maybe you mean activerecord-jdbcmysql-adapter? you can do a gem activerecord-jdbcmysql-adapter and installed. But AFAIK you just need it to use JDBC, normally with JRUBY. if you are using JRUBY i recommend you this site http://kenai.com/projects/jruby/pages/Home

链接地址: http://www.djcxy.com/p/33234.html

上一篇: ruby在Ubuntu上安装错误

下一篇: 未能安装activerecord