Better ways to install modules in Raku++

Raku++ comes with its own module manager. It uses a module store compatible with zef, but recent versions offer more convenient ways to install modules in bulk.

TL;DR:

Install all the dependencies used by the program:

$ raku install program.raku

Recursively install all the modules found in the directory:

$ raku install -r dist/lib

(Note that the raku command here and below is a symlink to rakupp.)

In detail

To test the new methods, you can choose to use a program specially added to the repository: examples/dirstat/dirstat.raku.

This program needs four modules from the Raku ecosystem and two its own modules located in the lib directory next to the program itself:

use lib 'lib';
use DirStat::Scan;
use DirStat::Tally;

use JSON::Native;
use Number::Bytes::Human :functions;
use Terminal::ANSIColor;
use Terminal::Boxer;

For the purpose of the experiment, you can first uninstall some of the modules if they are already installed locally, for example:

$ raku uninstall Terminal::ANSIColor;

Now, instead of manually installing modules one after another with raku install, you can install all the dependencies in a single go:

$ raku install examples/dirstat/dirstat.raku

This command will install all the ecosystem modules that the program requires, including their dependencies:

$ raku install examples/dirstat/dirstat.raku
examples/dirstat/dirstat.raku: a program — installing the 4 modules it uses, not the program
2 of the modules found by reading the source are installed already
plan (2 distributions, dependencies first):
  Number::Bytes::Human:ver<0.0.4>:auth<zef:raku-community-modules>   https://360.zef.pm/N/UM/NUMBER_BYTES_HUMAN/143aa3e9d5a629e2fcd5b68e7b0e240acfedf577.tar.gz
   . . .
testing Terminal::Boxer: 1 file
installed Terminal::Boxer:ver<0.3.1>:auth<zef:thundergnat>
done: 2 distributions processed into /Users/ash/.raku

From this output you can see that two of the four dependencies were already installed on my computer.

But you cannot yet run our test program by just providing its name:

$ raku examples/dirstat/dirstat.raku
Could not find DirStat::Scan in:
    lib
    lib
    rakulib
    /Users/ash/.raku
    /opt/homebrew/Cellar/rakudo/2026.09/share/perl6/site
    /opt/homebrew/Cellar/rakudo/2026.09/share/perl6/vendor
  (X::CompUnit::UnsatisfiedDependency)
  in block <unit> at examples/dirstat/dirstat.raku line 8
      8 | use DirStat::Scan;

The program uses the modules, which are not available in the Raku ecosystem. So, one of the possible solutions is to pass the location to them:

$ raku -I examples/dirstat examples/dirstat/dirstat.raku
 . — 569M in 83 kinds of file
 . . .
 …and 80 more; --top=83 shows them all

The program prints a table of file statistics by type and size in the current directory. I’ve deliberately omitted the output here.

The second method is to install the program’s own modules to your local module store. Again, instead of manually looping over them, install them recursively from their location:

$ raku install -r examples/dirstat
examples/dirstat: no META6.json above it — installing 2 modules as DirStat:ver<0>: DirStat::Scan, DirStat::Tally
plan (1 distribution, dependencies first):
  DirStat:ver<0>:auth<>   /Users/ash/raku++/examples/dirstat
installing DirStat:ver<0>:auth<> from /Users/ash/raku++/examples/dirstat
installed DirStat:ver<0>:auth<>
done: 1 distribution processed into /Users/ash/.raku

(In this example there are no nested directories, but that does not change the command: raku install -r <dir>.)

All the modules are now installed and Raku++ can find them, so just run the program:

$ raku examples/dirstat/dirstat.raku 

P. S. With the modules installed, the program also runs unchanged under Rakudo:

$ rakudo examples/dirstat/dirstat.raku

Leave a Reply

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

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code