How can you use multiple modules in a Raku project, if the modules are defined in the project?

181 Views Asked by At

I'm playing around with writing modules in Raku, when it made sense for me to break a piece of functionality off into another .rakumod file. How can I link these files together when I compile?

I tried to pull the other module to my main module via:

use MyProject::OtherModule;

But I get an error that it can't find this module even though they're side by side in the directory. I tried looking at some OSS projects in the Raku world, most of them are one file, the compiler Rakudo seems to use multiple module files but I can't figure out how they're linked.

Do I have to publish this module every time I want to run my project? How do I structure this if my project gets huge? Surely the best solution isn't to have it all in one file?

Edit: I should also note that I used this at the top of my new module too:

unit module MyProject::OtherModule;
1

There are 1 best solutions below

2
Coke On BEST ANSWER

When running locally, if you have your META6.json declared, you can use

raku -I. script.raku

and it will use the uninstalled versions, and you don't need to add any use lib in the script.