What is the best way to flush precompiled perl6 modules?

Precompiled modules are stored in the precomp directory. You can try to rename or delete the ~/.precomp directory.

See also this SO question here.


Update. Well I thought I'd replicated the scenario. It was reliably showing the bug during a one hour period. But now it isn't. Which is pretty disturbing. Investigation continues...


I've replicated @p6steve's scenario in case someone wishes to report this as a bug. At the moment I'm with @p6steve (per comment below) in that I'm going to treat this as a DIHWIDT rather than a reportable bug. That said, now we have a golf'd summary.

Original main program using path1 followed by the module it uses directly and then the one that uses:

use lib 'path1';
use lib1;
say $lib1::value;

unit module lib1;
use lib2;
our $value = $lib2::value;

unit module lib2;
our $value = 1;

This displays 1.

If the libs are copied to a fresh directory, including the .precomp directory, and then the lib2 is edited but the lib1 is not, the change to lib2 is ignored.

Here it is on glot.io before and after copying the libs and their .precomp directory and then editing the libs.

Original answer

Thank you for editing your question. That gives us all more to go on. :)

I'd like to try to get to the bottom of it and hope you're willing to have a go too. This (n)answer and comments below it will record our progress.

From your comment on @ValleLukas' answer:

Then I noticed ../lib2/.precomp directory - so realised library precomps are stored in the library folder. That did the job!

Here's my first guess at what happened:

You copied lib en masse to lib2. This copied the precomp directory with it.

You modified the use lib ... statement in mymain.p6 to refer to lib2.

Your mymain.p6 code includes a use module-that-directly-or-indirectly-uses-mylibrary.

You modify mylibrary.pm6.

But nothing changes! Why not?

You haven't touched module-that-directly-or-indirectly-uses-mylibrary, so Rakudo uses the precompiled version of that module from the lib2/.precomp directory.

Speculating...

Perhaps the fact that that precompiled version exists leads the precompilation logic to presume that if it also finds a precompiled version of a module that's used by module-that-directly-or-indirectly-uses-mylibrary then it can go ahead and use that and not even bother to check how its timestamp compares to the source version.

Does this match your scenario? If not, which bits does it get wrong?