25/08/2010

Rails3 on joyent shared (rvm way)

Here is the story of my attempts to get a rails3 app to run on a shared account @joyent.

Forword

First note the following:
- The app I want to run there is a toy I made mostly for myself and for fun but I would still like to have it on a 'real' server
- I own a lifetime joyent account (back when it was textdrive)
- I didn't upgrade to a private accellerator back then cuz I was short on cash
- The shared account sits mostly idle and I don't want to shell out monthly money for a toy app

Environment

I got the app working once using rvm and installing ruby-1.8.7-p299.
Before installing rvm you need to make sure it can find all the tools it needs. Many gnutools are defined as aliases in your .bashrc, rvm doesn't like that. the best way is to
[~] mkdir ~/bin
[~] cd bin
[~] ln -s /usr/local/bin/gdiff diff
[~] ln -s /usr/local/bin/gfind find
[~] ln -s /usr/local/bin/ggrep grep
[~] ln -s /usr/local/bin/gmake make
[~] ln -s /usr/local/bin/gpatch patch
[~] ln -s /usr/ucb/ps ps
[~] ln -s /usr/local/bin/gsed sed
[~] ln -s /usr/ucb/whoami whomai
[~] echo 'export PATH=$HOME/bin:$PATH' >> .bashrc

Make sure you logout / log back in

Installing rvm

From there, installing rvm is pretty straightforward following the installation guide works just fine:
[~] bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
The next step the rvm install guide recommends is to put
[~] echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"'>> .bashrc  # This loads RVM into a shell session.
I put it in bashrc as I wanted to have it for non interactive shells too (running rails and such).

Installing ruby

At the time of my first install, I didn't have a problem but with the recent version of rvm I recommend making sure that .rvm/gemsets/ruby/1.8.7/global.gems points to bundler --pre and doesnt force any kind of version.
[~] rvm install ruby-1.8.7 
which installed ruby-1.8.7-p299 (yes this is important)

Installing gems

I recommend you pre-install your gems. Bundler can use a lot of memory and go over the shared account limits. Manually installing the biggest gems first works just fine
[~] gem install rails --pre --no-ri --no-rdoc
[~] gem install bundler --no-ri --no-rdoc
[~] gem install sqlite3-ruby --no-ri --no-rdoc
[~] gem install capistrano --no-ri --no-rdoc
[~] gem install webrat --no-ri --no-rdoc
This would do it for me, bundler works fine after that.

What did _not_ work for me

ruby-1.9.2

installing ruby-1.9.2 fails on compilation with a link error, from what I understand opensolaris linker has a bug where it doesn't compile some bit of ruby correctly and makes ruby crash seemingly at random. To avoid random crashes ruby developpers added a test called bug-3662 which tried to link a lib called bug.so to detect the bug. I wasn't able to go any further.

Actually a joyent admin had a look into it and proposed a solution

capistrano

on either ruby-1.8.7-p299 or 1.8.7-p302 capistrano dies instantly with :
/users/home/user/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/i386-solaris2.11/openssl.so: ld.so.1: ruby: fatal: relocation error: file /users/home/user/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/i386-solaris2.11/openssl.so: symbol EC_GROUP_new_curve_GF2m: referenced symbol not found - /users/home/user/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/i386-solaris2.11/openssl.so (LoadError)
I assume this is linked with ruby 1.9.2 not compiling. Hopefully joyent will upgrade the environment and fix the linker... In the meantime, cap deploy works from my laptop

Aucun commentaire: