The Raspberry Pi is a credit-card sized computer with 700 MHz (can be overclocked to about 1.1 GHz) and originally 256 MB memory, which has recently received an upgrade to 512 MB.
Yukihiro Matz announced mruby in 2011 as Ruby implementation that is easily embeddable into other application and has a low memory footprint. mruby was open sourced in May 2012 with a C API
It is technically possible to install and run Ruby 1.9 on the Raspberry Pi, the standard MRI version will probably use up too many resources. While mruby is limited in its functionality (compared to standard Ruby), its properties are perfect for the resources available on the Raspberry Pi.
I assume you already installed a Linux distribution like Raspbian to the SD Card of your Raspberry Pi. There are currently no binary packages available for mruby, so we need to fetch the source and build it ourselves.
The source code of mruby is hosted on Github, and if you do not have Git installed on your system already, we need to install it:
We can clone the latest version of mruby directly from Github:
In order to build mruby, we need a C compiler and bison - a parser generator - installed on our system.
Now that all requirements are fulfilled go to your copy of mruby and type
This will compile mruby. Right now there is no
make install, which would install mruby on your system. You will have to use the binaries in
Adding mruby to PATH
You might want to add mruby to your PATH, so you do not have to call mruby with its full path all the time. Open up .bashrc in your home directory and add the following two lines at the end:
What to do now?
Now that you have mruby on your Raspberry Pi, you might ask: What do I do now?
Here are some ideas:
mruby is still under development and needs to be tested on different platforms. The Raspberry Pi (running on an ARMv6 architecture) is one of those platforms. If you find any bugs report them on Github!
Have a look at the C API and start to extend mruby with classes or modules to play around with. Maybe implement an ncurses wrapper for mruby?
Take your favorite Gem and port it to mruby! There already is a project to provide Gem support for mruby called mrbgems.
There are of course a lot of other things you can do with mruby. You are only limited by your imagination!
Did you already do something great with mruby and want to share it with the world? Leave a comment below!