Before we start exploring the Raku language, you should have an environment where you can run Raku code. So you need to install Rakudo, currently the only actively developed Raku compiler. Or even better, install Rakudo Star, which is a distribution that includes Rakudo itself, a few useful modules, and a tool that can help you install more modules.
Installing Rakudo itself gives you just the compiler. It follows a monthly release cycle, so it allows you to keep up to date with the latest developments.
When you choose to install Rakudo Star, which is typically released every three months, you get a more stable base for development and some tools like a debugger and a module installer. You can use the module installer to make use of prepackaged software libraries that are included neither in Rakudo itself nor in Rakudo Star. Some examples in this book will require some modules from the ecosystem, so you should install Rakudo in a way that lets you use zef, the module installer.
The following sections discuss a few options for installing Rakudo Star. Choose whatever works for you.
The examples in this book use Rakudo 2020.01 and should work with this or any newer version of Rakudo, as long as it supports Raku version 6.d.
The examples and source code used in this book can be accessed via the Download Source Code button at https://www.apress.com/9781484261088. You can also obtain the source code through git with this command: git clone https://github.com/apress/raku-fundamentals.git
2.1 Installers
You can download installers from https://rakudo.org/star for Mac OS (.dmg) and Windows (.msi). After download, you can launch them, and they walk you through the installation process.
Prebuilt Linux packages are available from https://github.com/nxadm/rakudo-pkg/releases/ for Debian, Ubuntu, CentOS, and Fedora.
In both cases, use version 202.01 to get the best compatibility with the examples used in this book.
Note that Rakudo is not relocatable, which means you have to install to a fixed location that was decided by the creator of the installer. Moving the installation to a different directory is not possible.
2.2 Docker
The option -v $PWD:/raku instructs Docker to mount the current working directory ($PWD) into the container, where it’ll be available as /raku. To make relative paths work, -w /raku instructs Docker to set the working directory of the Rakudo process to /raku.
I put this line into my ∼/.bashrc file so new shell instances have a rd command, short for “Raku docker.”
If you go the Docker route, use the rd alias instead of raku to run scripts.
2.3 Building from Source
You should have about 2GB of RAM available for the last step; building a compiler is a resource-intensive task.
If you are a Bash user, you can put that line into your ∼/.bashrc file to make it available in new Bash processes.
2.4 Testing Your Rakudo Star Installation
If, against all odds, all of these approaches have failed to produce a usable Rakudo installation, you should describe your problem to the friendly Raku community, which can usually provide some help. https://raku.org/community/ describes ways to interact with the community.
2.5 Documentation
Rakudo itself has little documentation, since most of the interesting material is about the Raku language. But Rakudo does come with a summary of command-line options that you can access by calling raku --help.
The official place for Raku language documentation is at https://docs.raku.org/, which aims to provide both reference and tutorial-style material. Other good resources are listed at https://raku.org/resources/, many of which are created and maintained by members of the Raku community.
2.6 Summary
On most platforms, you can install Rakudo Star from prebuilt binary installers. Where this doesn’t work, Docker images are available. Finally, Rakudo Star can be built from its sources.