# Newbie: OSX Ruby/MySQL issue?

**URL:** <https://www.ruby-forum.com/t/newbie-osx-ruby-mysql-issue/59971>\
**Category:** Rails\
**Created:** [May 9, 2006, 5:04am UTC](https://www.ruby-forum.com/t/newbie-osx-ruby-mysql-issue/59971 "2006-05-09T05:04:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85e7bf/32.png) [@Tim\_Jones](https://www.ruby-forum.com/u/Tim_Jones)\
**Post date:** [May 9, 2006, 5:04am UTC](https://www.ruby-forum.com/t/newbie-osx-ruby-mysql-issue/59971/1 "2006-05-09T05:04:27Z")

</div>

I’m three pages into the OnLamp RoR Tutorial [1] and am wrestling  
with what appears to be a MySQL connection problem.

I’ve created a simple controller called “recipe” with a corresponding  
“recipes” mysql table. The recipe controller is just a simple scaffold.

# When I browse to “recipe/new”, though, I get these errors:

# NoMethodError in RecipeController#new You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occured while evaluating nil.each

# Probing further (and checking the archives of this list, esp. [2]), I tried running script/console and querying MySQL directly. The results were:

> > ActiveRecord::Base.connection.execute(“SHOW FIELDS FROM recipe”)  
> > ActiveRecord::StatementInvalid: Mysql::Error: Lost connection to  
> > MySQL server during query: SHOW FIELDS FROM recipe  
> > from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/  
> > active\_record/connection\_adapters/abstract\_adapter.rb:120:in `log' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/ active_record/connection_adapters/mysql_adapter.rb:185:in `execute’  
> > from (irb):6  
> > ==

I’ve reinstalled all of RoR using a validcode.at bash script [3]–  
this supposedly fixed all the standard Tiger-Ruby bugs and enabled  
the ruby-mysql library, but I’m still having the same problem.

I’ve been googling for answers to this all night and am running out  
of ideas. Can anyone who’s familiar with the particulars of this  
setup give some advice?

Running: OSX10.4.4, Ruby 1.8.2, Rails 1.1.2, MySQL 4.1.16

Much thanks in advance for the help,

=Tim Jones=

> **[Tone Land](https://toneland.net/)**
>
> Tone Landはリトミックレッスン、親子イベントやこども向けコンテンツ、楽曲制作を行っています

[openboxoffice.com](http://openboxoffice.com)

[1] [Radar – O’Reilly](http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=3)  
[2] [http://news.gmane.org/group/gmane.comp.lang.ruby.rails/thread=59878](http://news.gmane.org/group/gmane.comp.lang.ruby.rails/thread=59878)  
[3] [http://sg.validcode.at/articles/2006/03/31/the-best-way-to-](http://sg.validcode.at/articles/2006/03/31/the-best-way-to-)  
install-rails-on-os-x

---

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85e7bf/32.png) [@Tim\_Jones](https://www.ruby-forum.com/u/Tim_Jones)\
**Post date:** [May 9, 2006, 6:57am UTC](https://www.ruby-forum.com/t/newbie-osx-ruby-mysql-issue/59971/2 "2006-05-09T06:57:00Z")

</div>

Hi Tim,

Not 100% on the same setup as you, but I have the Hivelogic install  
working here on X.4.6.

The first and most likely cause of your problems is here: [ /usr/lib/  
ruby/ ] in the quoted text below

> > > ActiveRecord::Base.connection.execute(“SHOW FIELDS FROM recipe”)  
> > > ActiveRecord::StatementInvalid: Mysql::Error: Lost connection to  
> > > MySQL server during query: SHOW FIELDS FROM recipe  
> > > from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/  
> > > active\_record/connection\_adapters/abstract\_adapter.rb:120:in `log' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/ active_record/connection_adapters/mysql_adapter.rb:185:in `execute’  
> > > from (irb):6

it should be /usr/local/lib/ruby/… instead of /usr/lib/ruby/…  
Note! /LOCAL/

and here: [Ruby 1.8.2,]

> Running: OSX10.4.4, Ruby 1.8.2, Rails 1.1.2, MySQL 4.1.16

In simpler terms, you have a problem with your PATH value in the  
your .bash\_login / .bash\_profile file. Sort that one out, close the  
Terminal window (or start a new session, or logout from your user a/  
c) and then run this simple test in a new Terminal/iTerm window at  
the prompt:

$ ruby -v

and you should get something similar to this returned: ruby 1.8.4  
(2005-12-24) [powerpc-darwin8.6.0] NB!! the ruby 1.8.4 in there,  
anything other than ruby 1.8.4 is NO good

IF things still don’t work after this, well then do what I do, check  
for typos carefully 😉 Alternatively, check my signature below for  
another Ruby/Rails install alternative 🙂

Kind regards,

Mats

* * *

“TextMate, coding with an incredible sense of joy and ease”

- [www.macromates.com](http://www.macromates.com) -

“RubyOnRails development done the Mac way”

- [locomotive.raaum.org](http://locomotive.raaum.org) -

---

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85e7bf/32.png) [@Tim\_Jones](https://www.ruby-forum.com/u/Tim_Jones)\
**Post date:** [May 9, 2006, 5:34pm UTC](https://www.ruby-forum.com/t/newbie-osx-ruby-mysql-issue/59971/3 "2006-05-09T17:34:23Z")

</div>

Success!

Had to do a huge amount of googling, reinstalling, recompiling, and  
solving additional errors but was ultimately able to get things  
running thanks to this advice. Much thanks, Mats.

=T=
