Hi folks. I’m just learning RoR, and I’m trying to get my development
environment up and running on my Windows machine. I am working through
Patrik Lenz’s book from Sitepoint, but am getting stuck because of the
esoteric way I set things up on my machine.
I already had the Ruby interpreter on my machine through Cygwin, so I
thought it would be simpler to install the gem manager, and then all
the related modules through Cygwin. Most of my web applications run in
a Linux environment, anyway, so I’m comfortable with this approach,
and it seemed to work pretty well.
Now here’s the tricky part. Cygwin only gives you binaries for some
programs. MySQL is not one of them. Usually, this isn’t a problem, so
I went to the MySQL web site, grabbed the current 5.0 Windows binary
and installed. (I actually had an older version, which I had to remove
first.) This wasn’t a big deal. I even got the mysql bin directory in
the $PATH variable in bash,
So here’s where things get bizzare. I build a table called stories in
the MySQL tutorial, just like in the book, and it works just fine.
Then I go to my Rails application and run scripts/console. Following
the directions in the book. I enter the following code:
class Story < ActiveRecord::Base; end
story = Story.new
This makes perfect sense to me, however, instead of getting a pleasant
response from the second line, I get about twenty lines of exceptions.
I won’t bother with the whole thing, but is starts off:
Errno::EBADF: Bad file descriptor - /tmp/mysql.sock
initialize' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/v endor/mysql.rb:107:innew’
real_connect' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/c onnection_adapters/mysql_adapter.rb:389:inconnect’
Of course, what’s happening is that because Ruby emulates a Linux
environment, it’s looking for the mysql.sock file in the most logical
Linux location, but because my MySQL install is vanilla Windows, its
not there, and there may not even be such a thing as a mysql.sock
file. As far as I can tell, this leaves me with two unpalatable
I uninstall the MySQL service, download the source, and spend hours
of my life trying to compile it from source under Cygwin.
I uninstall Ruby from cygwin, figure out where it placed gem,
rails, and all the other support files it installed so strange things
don’t happen in the future, and then install a vanilla Ruby / Rails
installation like everyone else.
Both of these options seem like a lot of wasted effort. Is there a
simple third solution that I am overlooking?