welcome to ruby gem hell or how not to spend your life configuring instead of coding

Thu, Nov 25, 2010

I’ve been working on a rails3 + dojo front end for a repository project and it’s been working fine on OS X. However, when I stuck it on linux and did bundle install this shit happens:

Installing nokogiri (1.4.3.1) with native extensions
…
error: ‘strdup’ undeclared (first use in this function)
First off, I’m not using nokogiri directly so some other thing must require it. That’s a pet hate of mine. No dependency management in rails. So I Googled and came up with this. It urges you to get nokogiri from git master branch, so I tried that:
git clone https://github.com/tenderlove/nokogiri.git
…
Getting pack list for https://github.com/tenderlove/nokogiri.git
…
Segmentation fault
How further forward am I now? Zero paces.

So I downloaded nokogiri 1.4.4.1 and attempted to build it from source:

rake install_gem
…
initialize': undefined methodcollect’
It turns out that something called rexical doesn’t work on ruby 1.9, so it urges you to use the ruby gem 1.8 stuff to install rexical and then use ruby gem 1.9 to install nokogiri. I tried that, installing rubygems but it just installed rexical in 1.9 and I don’t really see why I need to run two versions of ruby just to install a fecking gem that I don’t need.

How further forward am I now? Zero paces.

What I don’t understand is why I need some shit called rexical which doesn’t work with the latest ruby. My OS X “version” doesn’t require rexical and the gem isn’t installed and nokogiri is and it’s using ruby 1.9.2-p0. So WTF is the problem with ruby on linux as opposed to ruby on OS X? I find this happens every time I touch ruby. I spend 9 hours out of 10 sorting out dependency problems. It’s like I said. Spend your life configuring instead of coding.

How further forward am I now? Zero paces.

Eventually I got nokogiri master downloaded and did:

rake native gem
…
error: ‘strdup’ undeclared (first use in this function)
so the advice to get master for the fix was a load of bollox.

How further forward am I now? Zero paces.

If nokogiri requires rexical then either that’s not true, or the nokogiri gem on my OS X is broken, in which case I don’t need it as the app is fine, or the gems I see were somehow installed via ruby 1.8, which sounds horrific. All in all it’s a huge ruby dependency unmanaged shitehole! Anyway, I’m running under apache via passenger so I binned webrat and got round the nokogiri/rexical farce, only to come up against the next load of ruby shite:

error: expected specifier-qualifier-list before ‘sqlite3_backup’
The led to here. Which is a bug report that has been closed even although the bug has not been fixed and the bug does not show up in a search of the issues. Anyway, I installed sqlite3 via yast2, which is a fool’s game and I should know that really. Suse is shite and any rpms it installs are usually shite too. For example, I eventually had to compile openssl from source to get apache to work on suse linux as you end up in an endless loop with its rpm version of openssl, whereby apache requires the development rpm to configure itsself then barfs and requires the development rpm to be removed in order to compile, which fails as the headers are gone. And lo and behold suse has installed sqlite 3.6.4, to which the sqlite-ruby folk declare:
Ah, we don’t support sqlite3 that old. The extconf should have picked it up
well it didn’t so there’s no point claiming it will. So I tried binning the suse crap but python started moaning, as if I have any need of python. Then I tried to build the latest sqlite which complained it needed some crap called tcl sh (I can’t put the two halves of the word together or my blog blows up!). Eventually I did what everyone else who finds this error does and installs TCL.

So that was sqlite3 installed and I spent another half hour trying to force sqlite3-ruby to install. Stupid me. I didn’t realise you needed another – to specify gem options:

gem install sqlite3-ruby – –with-sqlite3-dir=/usr/local/sqlite3
and lo and behold, bundler finally finished:
Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed.
then I set up the production db:
export RAILS_ENV=production
rake db:create
rake db:migrate
and with an apache stop/start (restart didn’t work - it caused a passenger socket eruption) the app finally appeared. Minus all the dojo stuff. I was running in a subdir of a virtual host so I had to change:
<script src=“/javascripts/ltk/ltk.js” type=“text/javascript”>
to
<script src=“/ltk/javascripts/ltk/ltk.js” type=“text/javascript”>
and so on and finally, after many hours of battling ruby and rails and suse I had a working rails3 + dojo app installed and running under apache + passenger!

comments powered by Disqus