As explained in $Path hijacked by PacletManager? loading packages from custom directories may not be so intuitive. Not to mention absolute lack of documentation of interaction between
PacletDirectoryAdd, paclet's version etc.
Recent update to linked question explains something that hit me hard lately:
If you have
MyPackage` (V2) paclet installed in the default repo and
MyPackage` (V1) in a customDir. Then:
PrependTo[ $Path, customDir]; PacletManager`PacletDirectoryAdd @ customDir; << MyPackage`
will still load
MyPackage` V2 from the default repo.
I find this unexpected and really problematic because I failed to find a general enough way to manage this.
Real world use case
Let's say you are working on a dev branch developing V2.x. Part of testing involves packing it and installing locally, which means there will be V2.x in the default repo.
But before finishing V2.x you need to push a fix to V1 so you create another fix branch from the master branch (V1). You would like to load your code, but surprise, it loads V2.x from the default repo despite your changes to the
$Path and paclet directories.
How to make sure that
MyPackage`will be loaded from the
MyPackage`may contain 3rd part packages inside, e.g.
MyPackage/WL/GitLinkwhich it loads internally e.g. by temporarily blocking
GitLinkmay already be installed locally, newer or older, does not matter, the one from
customDir/MyPakcage/WLshould be loaded. Which means the solution can't be based on fixing the issue for
On the other hand
MyPackage`may require dependencies which are in the default repo so we can't just shield it off.