Rambles around computer science

Diverting trains of thought, wasting precious time

Mon, 17 Aug 2009

Ruby fails

I'm sure Ruby is a nice language, but I get slightly annoyed by two things whenever I try to install a Ruby program. One is that it has its own build system, as a replacement for Make et al---there are things called Rakefiles in the source distributions. The other is that it also has its own configuration and deployment system, based on the setup.rb script. These things annoy me because they're yet more tools that I need to learn, and for no good reason. Python is guilty of the same sins too. A new language shouldn't entail a whole new build system. (I won't go into why, but hopefully you don't need me to. I would also complain that there are too many languages, but I'll save that too.)

What really annoys me about Ruby is that setup.rb is broken, because it doesn't deal with prefixes properly. If I do ruby setup.rb config --prefix=${HOME}/opt, it still tries to install most of the program under /usr. So I tried giving the --prefix option to ruby setup.rb install too, but that doesn't do the right thing either. Instead it creates me a ${HOME}/opt/usr hierarchy and puts the stuff it was putting in /usr there.

I might as well come clean and admit that the only Ruby program I routinely install is iplayer-dl. Anyway, my next attempt: configure everything using paths relative to ./, then supply the overall prefix at install time. That doesn't work either---setup.rb interprets the ./ passed with --prefix, so you get install destinations relative to your configure directory. But only for files affected by --prefix, which isn't all of them.

Next attempt: configure everything relative to the root directory, then supply the prefix at install time. This does work, but you wouldn't guess from the output of ruby setup.rb install.

$ rubyver=$( ruby --version | sed 's/ruby \([0-9]*\.[0-9]*\)\..*/\1/' )  # horrible
$ rubyarch=$( uname -i )-$( uname -s | tr '[:upper:]' '[:lower:]' )           # horrible
$ ruby ./setup.rb config --prefix='/' --sysconfdir=/etc \
--libruby=/lib/ruby --librubyver=/lib/ruby/ --librubyverarch=/lib/ruby// \
--siteruby=/lib/ruby/site_ruby --siterubyver=/lib/ruby/site_ruby/ --siterubyverarch=/lib/ruby/site_ruby//
$ ruby $ ruby ./setup.rb install --prefix=${HOME}/opt
rm -f InstalledFiles
---> bin
mkdir -p /home/srk31/opt//bin
install iplayer-dl //bin//iplayer-dl
install iplayer-dl-gui //bin//iplayer-dl-gui
<--- bin
---> lib
mkdir -p /home/srk31/opt/lib/ruby/site_ruby/1.8
install iplayer.rb /lib/ruby/site_ruby/1.8/
---> lib/iplayer
mkdir -p /home/srk31/opt/lib/ruby/site_ruby/1.8/iplayer
install downloader.rb /lib/ruby/site_ruby/1.8/iplayer
install subtitles.rb /lib/ruby/site_ruby/1.8/iplayer
install metadata.rb /lib/ruby/site_ruby/1.8/iplayer
install preferences.rb /lib/ruby/site_ruby/1.8/iplayer
install browser.rb /lib/ruby/site_ruby/1.8/iplayer
install version.rb /lib/ruby/site_ruby/1.8/iplayer
install errors.rb /lib/ruby/site_ruby/1.8/iplayer
---> lib/iplayer/gui
mkdir -p /home/srk31/opt/lib/ruby/site_ruby/1.8/iplayer/gui
install main_frame.rb /lib/ruby/site_ruby/1.8/iplayer/gui
install app.rb /lib/ruby/site_ruby/1.8/iplayer/gui
<--- lib/iplayer/gui
<--- lib/iplayer
<--- lib
So, handily it's told me that it installed a bunch of stuff in /lib/ruby, which is exactly what I didn't want it to do. But, since I ran it without elevated permissions, I know that it can't have succeeded in doing that---yet there were suspiciously no error messages. Lo! Despite what it printed out, it has actually put the lib files in ${HOME}/opt/lib/ruby just as I wanted. Now, why was that so difficult?

To make matters worse, you of course have to set your Ruby path to get the deployed program to work, and that is also horrifying:

$ export RUBYLIB=${HOME}/opt/lib/ruby:${HOME}/opt/lib/ruby/site_ruby:${HOME}/opt/lib/ruby/site_ruby/1.8:
---disgusting, especially embedding the 1.8 version number in the path which will be seen (and interpreted) by any version of Ruby at all. It's following the pattern established Python, of course, and since Python has some reasonably sane people behind it I'm tempted to suspect that this ludicrous scheme has been selected for a reason---but even if this suspicion is correct, it'll have to be a very good one, and I somehow doubt that.

[/devel] permanent link contact

Powered by blosxom

validate this page