From Zero to Rails3 on Windows in 600 seconds

Posted by Matt Hulse on January 30, 2010|Comments
[Update:

Quite a lot has changed since this post was written. See Another Go with Rails 3 on Windows for a more up to date Rails 3 on Windows guide.

]



Some Prep Work

Download and install the following:
  • msysgit (Git for Windows) I'm using Git-1.6.5.1-preview20091022.exe
  • Ruby 1.9.1 I'm using rubyinstaller-1.9.1-p243-rc1.exe (Make sure to select the option to add Ruby\bin to your path)
  • Sqlite3 dll extract this into the bin directory of your newly created Ruby installation (c:\ruby\bin or c:\ruby19\bin)
That probably took about 300 seconds so we'd better get moving...

Showtime

Create a new directory for your rails app. Avoid spaces in the path. I'll be using c:\Rails3App Create a file called Gemfile in the root of your new directory with the following content:
gem "rails", git: "git://github.com/rails/rails.git"
git "git://github.com/rails/arel.git"
git "git://github.com/rails/rack.git"

require 'symlink' #hack to help bundler do it's thing on windows

#continue with other gems
gem 'rspec'
gem 'sqlite3-ruby'
Now create another file in the same directory called symlink.rb with the following:
require 'FileUtils'
# File.symlink hack (no symlink on windows)
class File
  def File.symlink(a,b)
    FileUtils.cp_r(a,b,:preserve => false)
  end
end
(Bundler depends on symlink which isn't implemented on Windows. This file provides a work around.)
Now open cmd.exe and cd to your new rails app directory:
cd c:\Rails3App
Install the new fangled bundler gem:
gem install bundler
Say the magic words:
gem bundle
Wait another 120 seconds and poof! You've installed Rails3. It's not installed like a normal gem though. Bundler put all of those gems directly inside this directory so to use rails type
bin\rails . -s
This uses the vendored rails gem to fill out the rest of the rails app in the current directory. Now when you view the contents of c:\Rails3App you will see a brand new rails3 application. You should be able to start up your new application like normal:
ruby script\server

The End

Give it a test run. This is still 3.0 pre alpha code so expect some hiccups but man, that was much easier than you thought it would be, right?




blog comments powered by Disqus