How do I put my packages into Dropbox
The easiest way is to modify $Path
to include the directory you placed your packages into. Suppose your packages directory is in the Dropbox\Documents\myPackages
folder inside your home
directory; then you can add it to your path like this:
AppendTo[$Path, ToFileName[{$HomeDirectory, "Dropbox", "Documents", "myPackages"}]]
(EDIT: amended according to advice by Steve Luttrell)
To make this change permanent, you can add this line to your init.m
file.
Each system (home and work PC) will have a custom line of this sort in its init.m
file that will tell Mathematica where to look for your packages.
Please note that since you are appending the new directory at the end of the path, system directories will have the precedence over custom ones. Just in case you decide to have the same names for different packages.
If you want your packages to have the precedence, you have to change the order your directory appears in your $Path
either by prepending it or by placing it at a custom position.
And now, for something extreme...
If you really want to have Mathematica look elsewhere for all its files, you might want to fiddle with $UserBaseDirectory
. I have no experience with that, but the documentation says that "the value of $UserBaseDirectory
can be specified by setting the operating system environment variable MATHEMATICA_USERBASE
when the Mathematica kernel is launched. It cannot be reset from inside the kernel". I guess that by copying the actual userbase directory to your new Dropbox location and then by specifying MATHEMATICA_USERBASE
accordingly in your OS environmental variables, you can get Mathematica to work directly with files in the Dropbox folder. But this is something you can do only on machines where you are an administrator, and it looks kinda risky...
Another solution would be to create a symbolic link if you are working on Linux or Mac OS X. I don't know how to do this in windows. In any case, for this example I put the MATLink
package in my dropbox folder. The location is the following:
/Users/jmlopez/dropbox/MATLink
To be able to use I need to put a shortcut to it
macbook-pro:~ jmlopez$ ln -s /Users/jmlopez/dropbox/MATLink /Users/jmlopez/Library/Mathematica/Applications/MATLink
Now I have two ways of accessing MATLink
, One from the Dropbox folder and one from the hidden directory $UserBaseDirectory
. Notice the dropbox icon.
I only provided this answer since I did not see anyone commenting on it. My preference would also be to modify the Kernel/init.m
file in the $UserBaseDirectory
as I would modify my bashrc
file.