metadatasoftware-distributionrakumodule-search-path

What is the difference between -I. and -Ilib in Raku?


I have a local distribution laid out as follows:

.
├── META6.json
└── lib
    └── Foo.rakumod

Both raku -I. -e 'use Foo;' and raku -Ilib -e 'use Foo;' compile and run, so which one should I use and why?


Solution

  • Another way of asking this question would be "What is the difference between -I $dir-with-meta6-file and -I $dir-without-meta6-file?". In this answer -I. will technically refer to -I $dir-with-meta6-file, and -Ilib will refer to -I $dir-without-meta6-file. Also note this covers use lib '.' and use lib 'lib'

    The difference between -I. and -Ilib can be briefly be summarized:

    Generally -Ilib gets used while developing, particularly when starting, because it is easier than manually adding/removing entries in the META6.json file. If you are writing a local application or something that is not intended to be installed this is mostly ok.

    However! -I. should be preferred once a META6.json file has be created for the distribution. This can be slightly more work to maintain manually, but it has a few advantages: