PhidgetSBC2 and ruby

Installing ruby (and the phidgets-ffi gem) on the PhidgetSBC2 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 gem like so:

gem1.9.1 install ffi phidgets-ffi

The gem doesn't find the libphidgetsbc.so.0 on the PhidgetSBC, 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

Leave a comment

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