Posts Tagged ‘windows’

Installing MySQL gem on Windows & cygwin for Rails

October 26th, 2008 by matt

This post assumes that you’ve followed the Setting up Rails on Windows with Cygwin guide and are using Cygwin on Windows for your Rails development.

If you’re upgrading to Rails 2.2 (or running on edge), you’ll need to build the mysql gem from source, as it’s being removed from the Rails pacakge. You’ll know if you need to do this if you get the following error when building your app:

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.

Installing MySQL from source

First thing you’ll need to do is to download the source files from MySQL.

The next steps are all from the command line (and will probably take a while to complete!):

tar xzvf mysql-5.0.67.tar.gz
cd mysql-5.0.57
./configure
make
make install

UPDATE: As those who’ve commented here have noted, a common error you may come across while running make is:

readline/readline.h:70:29: sys/ttydefaults.h: No such file or directory

The easiest way to solve this issue is to download the readline packages from cygwin (using the cygwin installer) and running

./configure --without-readline CFLAGS=-O2

Instead of plain ./configure

Also note, if you’ve already run ./configure you’ll need to clean up the directory by running

make distclean

This will actually install the entire MySQL library, but we won’t be using it. We just needed the library files to build the gem with. Once MySQL is built, you just need to install the gem, and you’re good to go:

gem install mysql

Don’t forget to tell MySQL which configuration we want to load. By default, it’ll try to use a local socket, but we want it to use the server we installed in Windows (outside of cygwin). Check out the Getting Cygwin/Rails to work with MySQL section of our previous guide.

Tags: , , ,
Posted in Guides | 21 Comments »

Setting up Rails on Windows with Cygwin

October 2nd, 2008 by matt

Update: If you’re using Rails 2.2, you’ll need to perform some extra work to get MySQL working.

Getting Started

I like developing in Ruby on Rails, but I don’t own a Mac.  I’ve found that setting up a Rails development environment within Windows can get frustrating and cumbersome at times.  I’ve also found that using Cygwin helps to keep all of the Rails related libraries all in one easy to manage location.  OK, enough of the boring stuff, let’s open up that command prompt and get started!

But wait!  Before we begin, I have to talk about one more thing.  One of the frustrating things for me while I was learning Rails was watching all of these Rails screencasts and seeing everyone use Textmate.  Textmate is awesome for Rails development, but it’s not available for Windows (and will probably never be).  Luckily, Alexander Stigsen has been developing a great Textmate app for Windows called “e”. I use e (the text editor) almost everyday and it is great for development in Rails (other languages have good support as well).  One cool thing is that e relies on Cygwin for some of the bundles, so if you do install and use e, you’ll get Cygwin as part of the package.

If you don’t want to use e, that’s cool too.  Just download the Cygwin setup file and follow the same steps (just ignore any asides about setting up e).  Let’s roll.

Installing Cygwin

First things first and that’s installing Cygwin.  Either grab the Cygwin standalone setup, or grab and install e and get to the Cygwin setup screens.

Note to e users: e will setup and install Cygwin the first time you run e, not upon installation of e.  Also, make sure to select “manual” configuration of Cygwin instead of “automatic”.

Read the rest of this entry »

Tags: , , ,
Posted in Guides | 12 Comments »