Let’s take a break from regular Ruby Everyday articles. In this episode, I’ll get Ruby 2.1 to run on my Kindle Paperwhite.

Jailbreak

First, go to Kindle Touch Hacking on MobileRead Wiki and jailbreak your Kindle. It’s pretty easy and straightforward, but do it at your own risk. Please make backups.

Install these things:

usbnet . This allows you to SSH/Telnet into your Kindle.

. This allows you to SSH/Telnet into your Kindle. KUAL: Kindle Unified Application Launcher . This launcher lets you run other applications on your Kindle, including the terminal emulator Kterm. You probably need to install mkk (MobileRead Kindlet Kit) as well.

. This launcher lets you run other applications on your Kindle, including the terminal emulator Kterm. You probably need to install mkk (MobileRead Kindlet Kit) as well. Kterm: A Terminal Emulator for Kindle Paperwhite. You can also download useful tools there, such as tmux and vim.

Now, you should have a Terminal on your Kindle!

Install Ruby

Download a precompiled Ruby binaries for Kindle from my repository, and follow the instructions.

You should then be able to invoke Ruby from your Terminal by using the full path (/mnt/us/opt/ruby-2.1.2/bin)

For example, to fire up irb:

# /mnt/us/opt/ruby-2.1.2/bin/irb

Link Ruby to /usr/bin

It is too tedious to have to spell out the full path name every time… We’ll link Ruby to /usr/bin so that it can be run instantly.

To make change to the root filesystem (outside of /mnt/us), we must switch to writable rootfs first, then we can create the symbolic links.

# mntroot rw

system: I mntroot:def:Making root filesystem writeable # ln -s /mnt/us/opt/ruby-2.1.2/bin/irb /usr/bin/

# ln -s /mnt/us/opt/ruby-2.1.2/bin/ruby /usr/bin/ # mntroot ro

system: I mntroot:def:Making root filesystem read-only

Add irb to the Menu Bar

We will add another menu item in KUAL for quick access to irb.

Go to `/mnt/us/extensions/kterm` and edit `menu.json`. Add another item to the menu, name it `irb`, and change its action to `bin/kterm_irb.sh`.

Inside the `bin` folder, make a copy of `kterm.sh`, rename that copy `kterm_irb.sh`, and open it for editing. On the line that invokes kterm, make it look like this:

${EXTENSION}/bin/kterm ${PARAM} -e irb

Now, when you go back to KUAL, you should see the irb menu item. Tap it, and you can write some Ruby code right away.

Source Codes

The source codes (Dockerfile) for building the toolchain and building Ruby are in the following repositories: