Message Boards Message Boards


How to enforce priority on custom directory over paclets default repository

Posted 2 months ago
0 Replies
0 Total Likes

Topic cross posted in

As explained in loading packages from custom directories may not be so intuitive. Not to mention absolute lack of documentation of interaction between $Path, PacletDirectoryAdd, paclet's version etc.

Recent update to linked question explains something that hit me hard lately:

The problem

If you have MyPackage` (V2) paclet installed in default repo and MyPackage` (V1) in customDir. Then:

PrependTo[ $Path, customDir];
PacletManager`PacletDirectoryAdd @ customDir;

<< MyPackage`

will load MyPackage` V2 from default repo.

I find this unexpected and really problematic

Real world use case

You are working on dev branch on V2, part of testing involves packing it and installing locally, which means there will be V2 in default repo.

Before finishing V2 you need to push a fix to V1 so you create another fix branch from master (V1). You would like to load your code, surprise it loads V2 from default repo despite your changes to $Path and paclet directories.


How to make sure that MyPackage` will be loaded from customDir?

MyPackage` may contain 3rd part packages inside, e.g. MyPackage/WL/GitLink which it loads internally e.g. by temporarily blocking $path and prepending MyPackage/WL. However, GitLink may be already installed locally, newer or older, does not matter, the one from customDir/MyPakcage/WL should be loaded. Which means the solution can be based on fixing the issue for MyPackage only.

p.s. will try to provide a code to play with later.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract