PhidgetSBC2 and ruby

Installing ruby (and the [`phidgets-ffi`][0] gem) on the [PhidgetSBC2][1] is fairly simple. You will need to check `Include full Debian Package Repository` under `System > Packages` in the SBC admin page. And then just ssh into the server and run the following:

apt-get update && apt-get install ruby1.9.1 ruby1.9.1-dev build-essential -y

And then you can install the [`phidgets-ffi`][0] gem like so:

gem1.9.1 install ffi phidgets-ffi

The gem doesn’t find the `libphidgetsbc.so.0` on the [PhidgetSBC][1], so we need to symlink it to somewhere that the gem will find it.

ln -s /usr/lib/libphidget21.so.0 /usr/lib/libphidget21.so

Once we’re done this we can test it with this:

ruby1.9.1 -rphidgets-ffi -e ‘puts Phidgets::FFI.library_version’

I also like to run this to add the `ruby1.9.1` executables (i.e. `rake`, `irb`, `gem`) without the `1.9.1` suffix.

update-alternatives –install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
–slave /usr/bin/erb erb /usr/bin/erb1.9.1 \
–slave /usr/bin/gem gem /usr/bin/gem1.9.1 \
–slave /usr/bin/rake rake /usr/bin/rake1.9.1 \
–slave /usr/bin/testrb testrb /usr/bin/testrb1.9.1 \
–slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1 \
–slave /usr/bin/irb irb /usr/bin/irb1.9.1

I also like to create an `.gemrc` to skip installing `ri` and `rdoc` documentation to save on space.

echo install: –no-rdoc –no-ri >> ~/.gemrc
echo update: –no-rdoc –no-ri >> ~/.gemrc

[0]: http://rubygems.org/gems/phidgets-ffi
[1]: http://www.phidgets.com/products.php?category=21&product_id=1072_0

Leave a Reply

Your email address will not be published. Required fields are marked *