12
$\begingroup$

How can I install packages in Mathematica Online?

In particular, how can I install the xAct package?

$\endgroup$
  • $\begingroup$ I should be the same way as with "normal" Mathematica: put them in $UserBaseDirectory/Applications. Use the file browser of Mathematica Online and navigate to Base/Applications. Place the package there, as described in the installation instructions. I have not tested this (also I don't have Mathematica Online, only the free version of the Programming Cloud). $\endgroup$ – Szabolcs Aug 9 '15 at 8:32
  • 1
    $\begingroup$ It seems parts of xAct rely on binary components called through MathLink. I expect that these will not work with Mathematica Online. $\endgroup$ – Szabolcs Aug 9 '15 at 8:34
  • $\begingroup$ @szabolcs That's probably true given that there are platform-dependent downloads. I didn't see it in the documentation though. Might it be that the Linux version works, given that WO probably runs on Linux? $\endgroup$ – Sjoerd C. de Vries Aug 9 '15 at 10:32
  • $\begingroup$ @SjoerdC.deVries I doubt it. To allow it to work, arbitrary MathLink programs should be allowed to run and that's probably too great a security risk. But it's only one package of the many that relies on an external MathLink program, xPerm. The rest of the packages should work, provided that they're loaded properly. The right way is not <<xAct` but <<xAct`subPackage` for each possible subpackage. The OP seems to not have read the introductory documentation. $\endgroup$ – Szabolcs Aug 9 '15 at 10:46
  • $\begingroup$ I tried to install xAct to the Programming Cloud (I don't have Mathematica online). Unfortunately, it seems that even if I just load <<xAct`xTensor` , it tries to load xPerm as well, which relies on an external executable. This is not supported in the programming cloud (and I'd assume the same for Mathematica Online too). For this reason, xAct seems not to be compatible with Mathematica Online. $\endgroup$ – Szabolcs Aug 9 '15 at 11:16
10
$\begingroup$

In general, packages need to be placed in the Applications directory within $UserBaseDirectory. $UserBaseDirectory has different locations on different systems. With standard Mathematica, we can just evaluate $UserBaseDirectory to find this location, e.g. on a Windows system:

$UserBaseDirectory

(* "C:\\Users\\JoeUser\\AppData\\Roaming\\Mathematica" *)

Also, SystemOpen[$UserBaseDirectory] will open it in the system's file manager.

Note: not all packages follow the standard so be sure to read the package's documentation for package-specific installation instructions.


What about the cloud? (Note: I do not have access to Mathematica Online so I am going to work with the Programming Cloud, hoping that they're similar enough.) The value of $UserBaseDirectory has less information about how to actually put files there, but we can navigate to Home > Base using the cloud's file manager:

Navigate to Applications and place the package there.

A package may be a single .m or .wl file, in which case doing this is simple, or it may come as a directory, which makes uploading more difficult. I have not found a way to upload a directory (please let me know if there's a way!), so I took the following approach instead: upload an archive and extract it using ExtractArchive. Or we can download the file directly to the cloud using URLSave. Using xAct as an example,

SetDirectory@FileNameJoin[{$UserBaseDirectory,"Applications"}]

URLSave["http://www.xact.es/download/xAct_1.1.1.tgz","xAct.tgz"]

ExtractArchive["xAct.tgz"];

DeleteFile["xAct.tgz"]

Now we have the xAct directory within Base/Applications, the package is installed.


How to install xAct specifically? xAct follows the standard installation procedure, so the above steps work. But unfortunately it is not compatible with Mathematica Online because it relies on separate executables, which are not supported in the cloud due to security reasons.

enter image description here

In short, this package won't work because it's written in a mix of Mathematica and C. Most packages written in pure Mathematica should work.

$\endgroup$
  • $\begingroup$ Thank you for the extensive answer; it's too bad that xAct is not supported on the cloud server. I made a link to this discussion at Mathematica feedback so perhaps it will be supported in the future. $\endgroup$ – Otto Aug 9 '15 at 12:49
  • $\begingroup$ It seems that in cloud focus on plug-and-play rather than serious development was shifted even more 147330 $\endgroup$ – Kuba Jun 5 '17 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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