Massaging Rails 3 Beta on Windows
Posted by Matt Hulse on February 05, 2010|
Comments
Ingredients: WinXP Pro, Ruby 1.9.1v243 (http://rubyinstaller.org)
Comments(Note: If you've installed an earlier version of bundler you'll need to 'gem uninstall bundler' first)
Installing:
Following the official instructions first we take care of some prerequisites:gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
I started from scratch so I needed rake as well:
gem install rake
Now the big kahuna:
gem install rails --pre
At this point you have the official Rails 3 beta installed. You'll want to check out all the posts going around documenting new changes in Rails 3, but for starters lets just start it up.
Let'er rip
Create a new rails app:rails rails3_beta ... cd rails3_beta
We need to let bundler take care of a few more dependencies now (note the new syntax, I dig it):
bundle install
Now we have what we need to run the server.
According to the new documentation, ruby script\server and other script commands are now called directly with rails from the root of the rails app. So 'rails server' should start up our webrick server on port 3000. Remember this is beta, so don't be discouraged when this doesn't work on Windows.
rails server #this doesn't work on Windows right now c:/ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2: command not found: C:/rails3_beta/script/rails ... in 'exec': No such file or directory - C:/rails3_beta/script/rails (Errno::ENOENT)
-Hiccup-
(excuse me)The problem is, 'rails server' attempts to execute the file 'script\rails' directly. Windows doesn't know what to do with this file because it has no extension. (Windows doesn't understand she-bang lines like #!/usr/bin/env ruby.) RubyInstaller has an option to associate .rb file extensions to the Ruby interpreter, allowing the execution of .rb files directly but that doesn't help us here because the file has no extension.
There are a few ways to deal with this:
- We could hack the railties bin\rails file to call this file with ruby.exe.
- We could hack the railties bin\rails file to call rails.rb and rename script\rails to script\rails.rb. As long as we checked the box to associate .rb files with the Ruby interpreter while installing, this will work the way it was originally intended to.
- In the short term, we can just substitute 'rails server' with 'ruby script\rails server', or 'rails generate scaffold test' with 'ruby script\rails generate scaffold test'.
So to run our new Rails3 app quick and dirty:
ruby script\rails server
you should now see the familiar webrick initialization and your server will be started on port 3000.
Go get'em Tiger!
Let's get in there and bang on it now, especially you folks on Windows. The benevolent forces that have given us Rails3 will need our feedback if we are going to have a viable Ruby ecosystem on Windows. If we don't tell them that we value a solid cross platform Rails experience, how will they know?Update
For those who prefer a screencast, Simon Bohlin has recorded these steps and more which can be viewed here. His experience was that he need to run "gem update --system" before installing rails3. (Actually by doing this, the first two steps are no longer necessary because RubyGems 1.3.6 fixes the issue with dependency resolution on prerelease gems. I guess things have changed enough since this was posted to warrant a new article.) He also takes this article a step further and installs the sqlite3 gem which is the default db in rails. Thanks Simon.blog comments powered by Disqus