Message Boards Message Boards


How to enforce priority on custom directory over paclets default repository

Posted 1 year ago
2 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.

2 Replies

Did you get an answer to this question? I recently put my package into a paclet and don't know how to control which one loads. Do I have to provide the full path now when I do Get["mypackage"]?

Posted 3 months ago

No I did not.

To force loading from the workspace rather than the default paclets directory I tend to do

PacletUninstall /@ PacletFind @ "name"

It can only uninstall from default repo so don't worry about the workspace.

If you have multiple development versions simultaneously on path, then I don't know. I only one development version and to switch I checkout different commits/branches in git. Then RebuildPacletData[] updates.

The problem with Get @ absolute/path is that it will not affect Get calls inside your paclet. So if you have Get @ name`name` then it will point somewhere else.

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

Group Abstract Group Abstract