Ruby is a language I've been meaning to learn for some time now and I figured I'd do that by using it for one of my projects here at Bug. The first thing I went to do was install RubyGems, the package manager for Ruby (much like pip and easy_install for Python), but I couldn't get it to work. It turned out that our default install of Ruby is missing some modules from the Ruby Standard Library, specifically socket, which RubyGems uses for fetching Ruby packages, or gems, from the internet.
As it was high time that I learned our build system anyway, I spent the next couple of days getting a working install of Ruby onto our repository. The package just went up an hour ago, so it's time for some documentation.
The first step is to make sure you have our extra ipkg repositories enabled:
root@BUG:~# wget http://repo.buglabs.net/ipkg-extras.conf -O /etc/ipkg/ipkg-extras.conf
root@BUG:~# ipkg update
After this, you can go ahead and upgrade Ruby to the latest version:
root@BUG:~# ipkg install ruby
A few dependencies might get installed. As of this writing, the latest version of Ruby in our repositories is 1.8.6-p399. Anything earlier than this won't work. I know that Ruby 1.8.7 is out, but I had some trouble compiling it. If you want to take a whack at it, I would be more than happy to help you along the way.
The next step is to install RubyGems. At some point, I would like to create an ipkg for this as well, but for now, we'll install it from source. It's very easy to do. As of this writing, version 1.3.6 is the latest version, but do check their downloads page to make sure. Be sure to run these commands from your home directory (type 'cd', no quotes, at the command line to get there).
root@BUG:~# wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz
root@BUG:~# tar xvzf rubygems-1.3.6.tgz
root@BUG:~# cd rubygems-1.3.6
root@BUG:~# ruby setup.rb install
Once you have installed RubyGems, you can remove rubygems-1.3.6.tgz and the rubygems-1.3.6 directory.
Some gems have native components that need to be compiled. This includes SerialPort which I will be using for my project. In order to be able to build these on the bug, we need to install our build tools:
root@BUG:~# ipkg install task-poky-sdk
Then you can install your gem (--no-ri and --no-rdoc make the install process go faster, you probably don't need Ruby docs on your BUG anyway).
root@BUG:~# gem install serialport --no-ri --no-rdoc
And there you have it! To verify that you're good to go, you can run the Interactive Ruby Shell:
irb(main):001:0> require 'rubygems'
irb(main):002:0> require 'serialport'
You can even install Rails, the popular web framework written in Ruby (I've only tested if it installs, not if it actually works, but I don't see a reason it shouldn't):
root@BUG:~# gem install rails --no-ri --no-rdoc
So go forth and code, young Rubyist. Please feel free to ping me if you have any issues. You can find me on IRC in #buglabs on Freenode as davidbalbert.