tags:

views:

814

answers:

4

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

A: 

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

VP
I haven't chosen to use JBury anywhere, that seems to have happened by itself. As I said I installed with $ gem install rails os OS X 10.6 so whatever that does, is what I have.
Phil Sturgeon
+1  A: 

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.

Zack
Sorry Zack you mentioned this in a Tweet and I totally forgot to reply. I have XCode installed and it's working nicely, this was a different issue. Thanks for responding though, always appreciated.
Phil Sturgeon
A: 

Works for me with:

gem install --platform java activerecord-jdbcmysql-adapter

Realized it wasn't defaulting to the correct platform after seeing on http://rubygems.org/gems/activerecord-jdbcmysql-adapter that the version was hyphenated -java.

(Did a "gem update --system" just prior. Not sure if it had any effect on this.)

Oh and yeah, for Mysql you will need xcode and possibly additional headers to be installed for mysql.

litui
+1  A: 

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!

Phil Sturgeon