“windows” man walking
“windows” man walking. “windows” man walking here.
So you found Merb. You’re on a Windows desktop. Something feels wrong, but you know you can do this Merb stuff if you could only get it installed. You’ve gone to the Merb wiki and now you’re a little confused. Merb is almost 1.0 but not quite and you want to be on the “edge”. Cygwin sounds funny to you and you think it’s “that terminal thing”. All the kids are doing Rails, but this Merb thing sounds “cooler”.
Does this sound like you? No? I keed, I keed.
Get the environment
Click here and download the setup.exe and run it.
Now when you get to the “Select Packages” screen we need to grab a few of the necessary packages to facilitate a Merb environment. From the “Select Packages” screen click on the “View” button until it shows “Full”.
From the list select all of the following packages:
- curl
- gcc
- gcc-core
- gcc-g++
- git
- libiconv
- libiconv2
- libxml
- libxml2
- libxml2-devl
- make
- ruby
Click next and watch the downloads. When it’s done it will ask to put a shortcut on the desktop and in the start menu. Open Cygwin and you’ll be greeted by a message about group names and domain users. Ignore this or run the example commands - your choice. The command line will be below this and will look like this:
you@yourmachine ~ $
This is showing the terminal is launched and starting in your home directory (~). If you don’t know what to do with a Terminal - this post will be OK for you but your not going to learn everything here. You should know how to navigate directories and tar. Good? Good.
I have a Terminal - now what?
Let’s start by checking we have Ruby. From the command line run:
$ ruby -v
You should see:
ruby 1.8.7 (2008-06-20 patchlevel 22) [i386-cygwin]
1.8.7 or 1.8.6 are acceptable version numbers. Now lets get RubyGems installed. Download this and then from inside Cygwin navigate to the directory you saved that file. (Like I said - if you don’t know how to do this go elsewhere to find out how to cd your way around):
$ cd /cygdrive/c/Documents\ and\ Settings/you/My\ Documents/ $ tar xzvf rubygems-1.2.0.tgz
You should see the RubyGems directory extract out from the tar file. Now run the setup for RubyGems:
$ cd rubygems-1.2.0 $ ruby setup.rb $ cd ..
It should end with a nice little message from the RubyGems team.
Can I Merb yet?
Almost. We actually need to get Merb first. The rest of this post will politely be stolen from this post. There are a few hiccups along the way due to Cygwin and Windows that I will address.
First let’s grab dependencies:
$ gem install erubis rake json json_pure rspec rack hpricot mime-types ruby2ruby\ ParseTree memcache-client templater haml mailfactory sequel mongrel libxml-ruby\ english addressable builder
This will crash out right after ruby2ruby-1.1.9 is successfully installed. You will see:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/lib/ruby/gems/1.8/gems/ParseTree-2.2.0/History.txt
I don’t know why this is exactly. But I know how to work around it. Do the following:
$ gem uninstall ruby2ruby $ gem uninstall ParseTree $ gem install ruby2ruby
Type “Y” to remove the executables and during the install you will see ParseTree comes with ruby2ruby as a dependency. Now finish the rest of the list above:
$ gem install memcache-client templater haml mailfactory sequel mongrel libxml-ruby\ english addressable builder
Once the dependencies are taken care now we can go grab Merb itself.
Thor
Thor is helpful because it provides a nice way to use Rake tasks to grab the git repos of Merb and install the edge versions. Let’s get it:
$ git clone git://github.com/wycats/thor.git cd thor rake install
NOTE: As of Sept. 24 2008 this git version does not work. The rake task doesn’t work. Do this:
$ gem install thor
Possibly within the next few days the git repo will be updated. It looks as though it is utilizing Thor within the Rake task. Real dogfooding.
Now that we have Thor let’s use it to grab the Merb tasks:
$ thor install http://merbivore.com/merb.thor
This will prompt for a name - call it “merb”.
Merb
Now is the good stuff. First we need to move to a directory that is free of spaces in the name. So do this:
$ cd /cygdrive/c $ mkdir merb_source $ cd merb_source
Once you have this setup now do this:
$ thor merb:edge:core --install $ thor merb:edge:more --install $ thor merb:edge:plugins --install
This will roll through the process of grabbing the source, creating the gem packages and install all of them. You will have Merb - but don’t you want DataMapper too?
DataMapper
DataMapper does what ActiveRecord does, but in a much different way. It has some nice features that any ActiveRecord fan should look into. Here is how to grab it:
$ thor merb:edge:dm_core --install $ thor merb:edge:dm_more --install
But there is a small snag in this. A pretty important gem gets skipped. The easy way around this is to do it ourselves:
$ cd src/dm-more/pkg $ gem install merb_datamapper --local
Installed!
As you can see there are a few steps but they are pretty easy. And if you didn’t catch the reference above to “dead man walking” - I think this could be the gateway for a lot of developers to move away from Windows. Just my personal opinion !