Installing Merb

Posted by yossarian

I took a crack at installing Merb today, just to see how it works out. It’s a very minimal Ruby framework which in my (admittedly not very scientific) testing appears to be a lot faster than Rails, especially under conditions of high concurrency.

To get it running, I followed the instructions at the Merb book which is currently a work in progress at http://4ninjas.org. A quick tip: due to a dependency on extlib 0.9.3, the sake edgy technique didn’t work for me at first. I got it all running happily by doing the following.

First, install the Git source-code management tool and the Debian build tools if you don’t already have them:

sudo apt-get install build-essential git-core
sudo gem install rack mongrel json erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory  english addressable templater

Update: in the last few weeks gem dependencies have changed and you need to ensure you’ve got some specific versions available:

sudo gem install ruby2ruby --version=1.1.8
sudo gem install ParseTree --version=2.1.1

You’ll also need to ensure that you’ve got the MySql headers available in order to build the datamapper MySql libraries.

sudo apt-get install libmysqlclient15off libmysqlclient15-dev
git clone git://github.com/sam/extlib.git  
git clone git://github.com/sam/do.git

cd extlib
rake install ; cd ..
cd do
cd data_objects
rake install ; cd ..
cd do_mysql  # || do_postgres || do_sqlite3
rake install

For whatever reason, DataMapper 0.9.4 has a dependency on Merb-core 0.9.3, so you’ll need to install it and then proceed to build the newest DataMapper:

sudo gem install merb-core

git clone git://github.com/sam/dm-core.git
git clone git://github.com/sam/dm-more.git

cd dm-core ; rake install ; cd ..
cd dm-more
rake install; cd ..

After that stuff, the

sudo gem install sake
sake -i 'http://edgy.4ninjas.org/edgy.sake'
sake edgy:install packages="merb-stack"

commands worked just fine for me.

Bonus: install CouchDb, the wicked distributed database system which is currently an Apache incubator project.

sudo apt-get install build-essential erlang libicu38 libicu-dev libmozjs-dev
wget http://www.apache.org/dist/incubator/couchdb/0.8.0-incubating/apache-couchdb-0.8.0-incubating.tar.gz
tar -xvzf apache-couchdb-0.8.0-incubating.tar.gz 
cd apache-couchdb-0.8.0-incubating/
./configure
make && sudo make install

You can set up the CouchDb datastore as a service, with its own user, like this (thanks to these instructions, slightly modified to avoid the creation of a “couchdb” home directory):

sudo useradd couchdb
sudo mkdir -p /usr/local/var/lib/couchdb
sudo chown -R couchdb /usr/local/var/lib/couchdb
sudo mkdir -p /usr/local/var/log/couchdb
sudo chown -R couchdb /usr/local/var/log/couchdb
sudo mkdir -p /usr/local/var/run
sudo chown -R couchdb /usr/local/var/run

sudo cp /usr/local/etc/init.d/couchdb /etc/init.d/
sudo update-rc.d couchdb defaults
sudo /etc/init.d/couchdb start

After that, go to http://localhost:5984/_utils/index.html and you can administer your new distributed datastore. Of course, you could just ignore CouchDb and use Merb with a more “normal” database server like Mysql or Postgres.

If any of the version dependencies change again please leave a comment and I’ll update these instructions until Merb 0.9.4 is a little easier to get.

Comments

Leave a response

  1. Richard HeycockJuly 17, 2008 @ 10:25 PM

    Just a quick heads up on couchdb. Version 0.8 was released a few weeks ago and there is a debian package for it so you can just download and install that. Not sure of you level of experience with hardy/debian, some please forgive me if you already now this:

    • download pacakge
    • dpkg -i <package> (This will fail due to dependencies)
    • apt-get install -f (Install the dependencies and finish of the installation)

    Having said that instatalling it from scratch is pretty easy and generall Just Works.

    Also there are a few problems with version 0.8 due to a possible mochi (the new http server they are using) so if you want to use it in production you might want to stick with 0.7.2. You should be aware, however, that there is an on disc format change between 0.7 and 0.8. There is an upgrade path of course!

    Just to finish I’ve been using couchdb in a production system for about 4 months now and it’s never failed me. There are some funnies with it but on the whole it’s an impressive bit of kit.

  2. Peter BolingAugust 04, 2008 @ 06:07 PM

    I had to modify a few things to get this to work… Right off the bat installing these gems should help lessen the number of workarounds you need to get merb running!

    sudo gem install english addressable sudo gem install ruby2ruby—version=1.1.8 sudo gem install ParseTree—version=2.1.1

  3. yossarianAugust 12, 2008 @ 01:29 PM

    @Peter: the instructions worked a couple weeks ago but I guess things are moving too fast. I’ve updated the article with the new version dependencies, I just ran into the exact same problem when attempting to install on a fresh box!

  4. yossarianAugust 12, 2008 @ 03:10 PM

    @Richard Heycock: for stuff like this I always waver between “find a deb somewhere”, “get the source and build a deb from it”, and “just use the source.” In this case the straight up configure && make && sudo make install seems be working nicely so I’ll stick with it. Just out of interest though, is the .deb file in the regular debian repos somewhere or is it available somewhere else?