In this tutorial I’ll get you through setting up a Raspberry Pi with Perl 6. I am using a Raspberry Pi 3 myself, but other versions should work fine too. However, older versions are slower, so it might take a bit longer to install completely.

For those who have never had a Raspberry Pi before, you will need the following:

  • Raspberry Pi board

  • Power supply (5v 2A, micro USB)

  • SD card of at least 4gb, but I would advise at least 8gb

  • Monitor with HDMI cable

  • Keyboard

Perl 6 will be installed using Rakudobrew, which I’ll also be using to get zef installed. Zef is the recommended module manager for Perl 6.

Setting up Raspbian

The first step is getting the OS set up. To keep this tutorial simple, I will stick to Raspbian, but if you feel confident in your skills you can use any other distribution or OS. Perl 6 installs the same on all UNIX(-like) operating systems.

Get the image

First, download the Raspbian image from the Raspberry Pi download page. I chose the LITE version, but if you prefer having a graphical desktop you can go for the DESKTOP version instead.

At the time of writing, this means I got the 2017-09-07-raspbian-stretch-lite.zip. If you want to verify you got the correct download and nothing went wrong saving it to your disk, you can verify the checksum. The checksum for your download is noted below the download links. To get the checksum of the file you downloaded, use sha256sum as follows:

Lines prepended with a $ are to be ran as your normal user, whereas lines with a # are ment to be ran as "super user". This can be done by using a privilege escalation program, such as sudo.
$ sha256sum 2017-09-07-raspbian-stretch-lite.zip

If the checksum matches the one noted below the download button you used, it should be fine, and you can continue with extracting the image from the zip using unzip:

$ unzip 2017-09-07-raspbian-stretch-lite.zip

This will result in a similarly named file, but with a .img extension instead of .zip. This is the image that you can write to the SD card.

Write the image to the SD card

This step is pretty easy, but typos here can be disastrous for the system you’re using to write to the SD card.

Open a terminal and run dmesg -w as super user (usually doable using sudo dmesg -w). This will give immediate feedback when you insert your SD card, and shows which device it is being assigned to. In my case, this was sdb, which means the device file resides at /dev/sdb.

Now, to actually write the image, I’ll use dd since this is everyone’s favourite tool, it seems. If you feel adventurous enough to try out something different, feel free to read up on Useless Use of dd.

Make sure to make the if argument point to the correct path with your extracted raspbian image, and of to point to the correct device as identified earlier. In order to be allowed to run this command, you must be root, which can be achieved by using sudo or doas again.

# dd bs=4M status=progress if=/path/to/2017-09-07-raspbian-stretch-lite.img of=/dev/sdb
$ sync

Afterwards, plug it into your Raspberry Pi and attach all cables you might need. Think of stuff like a keyboard, mouse, monitor, internet, power. Do power last, as the Raspberry Pi will start immediatly once it receives power.

First boot

The Raspberry Pi should start booting the moment you supply it with power. If you attach the HDMI after the power, it’s possible you won’t have display working, so make sure HDMI is attached before powering up.

You’ll see some text scrolling by, up to a point where it asks you for a login, and accepts keyboard input. The default username is pi, and the default password is Raspberry. You are strongly advised to change the password upon login, which can be done in the next step.

Configuration

The Raspberry Pi comes with its own configuration tool, raspi-config. Run this with sudo prepended in front of it so you gain the right privileges. I would advise you to at least change the user password from here. After this you should go to Advanced Options and expand the filesystem. This will grow the filesystem to the entire SD card’s size.

To get to the buttons on the bottom (Select, Finish and Back), use the arrow keys to go left or right.

You can look around the tool for other interesting things to modify. Once you are satisfied, go back to the main menu and choose Finish. It will ask to reboot, which you should accept. This will apply all the new configurations you just made.

Updating and installing additional packages

It’s rare for the system to be completely up to date after installing the image on the SD card. Additionally, you also need some extra packages in order to get rakudobrew, and to install Perl 6 itself. For this, we use the package manager bundled with raspbian, apt:

# apt update
# apt upgrade

This will update the package lists, and then upgrade all outdated packages to their newest versions. You should do this at least once a week to make sure your system stays up to date.

Once the upgrades are finished, you can install some new packages which are needed later on in this tutorial:

# apt install git build-essential

git is required to get the rakudobrew repository and is also used by rakudobrew itself to get the sources needed to build Perl 6 and to install zef. The build-essential package comes with all sorts of tools to build software, which is required to build Perl 6.

Installing Perl 6

Now, we’ve got a working Raspberry Pi installation. We can start doing things with it, such as playing around with Perl 6.

Setting up Rakudobrew

Rakudobrew is a nice tool to manage Perl 6 installations on your system. It can also install zef for you, so you don’t have to deal with this manually. This is all documented on the repository’s README.md file as well, but I’ll explain it here too. I do make a few small tweaks here and there to match my preferred setup more closely.

Clone the repository to your system, and add it to your $PATH to be able to use the scripts bundled with it:

$ mkdir -p ~/.local/var
$ git clone https://github.com/tadzik/rakudobrew.git ~/.local/var/rakudobrew
$ export PATH=${HOME}/.local/var/rakudobrew/bin:$PATH
$ hash -r

The hash -r call will rehash your PATH, so you can tab-complete rakudobrew. Next, initialize rakudobrew:

$ rakudobrew init

This will give you a notification to automatically load rakudobrew next time. It is advised you follow that message, so you won’t have to do it manually each time you log in to the system.

Installing Perl 6 with MoarVM backend

Now that rakudobrew is installed and available to use, it’s time to make use of it to install Perl 6.

$ rakudobrew build moar

Installing zef, the module manager

Getting zef to work isn’t much harder than installing Perl 6, but its a lot faster. You can have rakudobrew take care of this too:

$ rakudobrew build zef

Final words

And that should be it, you now have a working Perl 6 installation with the zef module manager to take care of installing and upgrading modules. Now you just need to come up with a nice project to work on to start using and learning the wonders of Perl 6.

If you need any help on getting started, try the #perl6 IRC channel on Freenode, or check out some of the Perl 6 documentation and introduction sites:

For starting projects that are easy to start with and can bring quick results, consider making an IRC bot using IRC::Client, or a small web application using Bailador.