Message Boards Message Boards

1
|
9643 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to enforce priority on custom directory over paclets default repository

Posted 6 years ago

Topic cross posted in mathematica.stackexchange.com

As explained in https://mathematica.stackexchange.com/q/59127/5478 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.

Questions

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.

POSTED BY: Kuba Podkalicki
3 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 BY: Eric Smith

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.

POSTED BY: Kuba Podkalicki

Hello from 2024!

We are struggling with the same problem. It breaks the whole idea of having local version fixed packages in the project. Most projects PacletUninstall is the only solution

POSTED BY: Kirill Vasin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract