Windows Mac-alike Rails Development Environment

Published on January 3, 2011 by , in Rails

As I already been using e-texteditor (for quite a few years), which is a clone of Mac-only Textmate, I thought to give setting up a mac-alike rails development environment a go.

Since I had a ton of compatibility problems when developing under vanilla Windows (with Ruby1.9 and rails3, a lost of gems failed to work, etc.), I hope the Unix-path is much smoother.

Let’s see how we can get it going…

Step 1: Install cygwin

You will need in to select the following in addition to the the default selected configuration (italic = requirements for the Nokogiri gem):

  • make
  • gcc
  • libiconv
  • openssl
  • ruby
  • libiconv
  • libxml2
  • libxml2-devel
  • libxslt
  • libxslt-devel

Step 2: Use Console with Cygwin by default

Console was one of the tips I didn’t know about ( http://sourceforge.net/projects/console/ ), it’s much nicer than the old ‘cmd’, and most of all you can set it up to start a cygwin console by default

Quote from http://garbageburrito.com/blog/entry/391/a-macesque-rails-development-environment-on-windows:

You’ll want to setup cygwin as a Console Tab. Just go into the settings and click “Add” under “Tabs”. Use the following as the “Shell”.

c:\cygwin\bin\bash --login -i

If you want it to automatically open cygwin when you start Console, just move it to the top of the Tabs list.

Just in case you encounter errors with

rvm install 1.8.7

Checkout this post about readline: http://rvm.beginrescueend.com/packages/readline/.

rvm package install readline

Step 3a: Ruby 1.8.7

Ruby 1.8.7 is already installed in cygwin, so if you want to use this one, you’re ready to go.

Step 3b: If you want RVM

Follow the instructions from http://rvm.beginrescueend.com/rvm/install/

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

Modify ~/.bash_profile by appending at the very end, after all path loads etc:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

Install ruby with

rvm install 1.8.7
rvm install 1.9.2

Step 3c: Compile Latest Ruby (without RVM)

Download the Ruby 1.9 source from http://www.ruby-lang.org/en/downloads/ (downloaded the latest stable Ruby 1.9.2-p136 at the time of writing)

tar xvf ruby-1.2.2-p136.tar.gz
cd ruby-1.9.2-p136
./configure

(lasts ~5-10 minutes)

make -j 3

(use 3 if you have 2 cores, 5 if you have 4 cores, etc.)

make install
ruby -v

to confirm the new version

(find more in-depth instructions here: http://www.curphey.com/2010/05/installing-and-configuring-ruby-1-9-from-source-using-cygwin/)

Step 4: Avoid the default installation of ri and rdoc from ruby gems

To avoid the installing of documentation (as I usually check the online documentation):
create .gemrc file in your cygwin home directory (~) with the following contents:

gem: --no-ri --no-rdoc

Step 5: Install sqlite

Downloaded the latest sqlite tarball containing the amalgamation for SQLite 3 from http://www.sqlite.org/download.html.

tar xvf sqlite-autoconf-3070400.tar.gz
cd sqlite-autoconf-3070400
./configure
make -j 3

(use 3 if you have 2 cores, 5 if you have 4 cores, etc.)

make install

Step 6. Install Rails 3

gem install rails

Step 7. Create & start the first Rails3 app

rails new testapp
cd testapp
bundle install

(this will install sqlite3-ruby gem)

rails s

That’s it!