On Desktop, I can install a custom package in the Applications directory under AddOns. This path appears in $Path and loading the package is successful.

On Cloud, I tried to install a package in "Base`Applications`" like I would on Desktop, but the only way loading the package has worked is if I run Prepend[$ContextPath, "Base`Applications`"] at the beginning of a notebook. The path to Base/Applications exists on the $Path.

Can the context be set automatically? Where is one supposed to install a package? Is this a bug?


closed as off-topic by Pinti, m_goldberg, Henrik Schumacher, LCarvalho, user21 Jun 13 at 6:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Pinti, m_goldberg, Henrik Schumacher, LCarvalho, user21
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ You can install them normally in $UserBaseDirectory/Applications just like in Desktop Mathematica I believe. $\endgroup$ – b3m2a1 May 25 at 19:55
  • $\begingroup$ Does it answer your question? mathematica.stackexchange.com/q/175543/5478? $\endgroup$ – Kuba May 26 at 7:43
  • $\begingroup$ This helps, but it seems there is a bug. I have checked the $Path and it contains the cloud path. I moved the package file to that location, but I have seen inconsistent results unless I run Prepend as mentioned. Even this fails on the mobile app sometimes $\endgroup$ – Dan Kowalczyk May 26 at 16:47
  • $\begingroup$ @DanKowalczyk it is hard to help without a clear description of steps that lead to a problem $\endgroup$ – Kuba Jun 3 at 6:37

I made a mistake by trying to import the context that the file defines, not the file itself. D'oh!

The package I tried to import is defined in a file named $UserBaseDirectory/Applications/Package.m. The context it defines is Package`Main`. I was running Needs["Package`Main`"] because as a newbie I thought imports must refer to the context, however this fails.

I am now able to import successfully by simply specifying the filename as Needs["Package`"]. This works because the $Path contains $UserBaseDirectory/Applications/.

  • 1
    $\begingroup$ You could expand on this giving a proper answer to your original question (basically saying that $UserBaseDirectory works) and then mention what happened to you. $\endgroup$ – b3m2a1 Jun 7 at 17:23
  • $\begingroup$ Thanks for reviewing this and for your suggestion. I added some more details. $\endgroup$ – Dan Kowalczyk Jun 8 at 3:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.