# How do I put my packages into Dropbox

I don't want to necessarily put my packages in Mathematica's $UserBaseDirectory, which is on my local hard drive. Can I somehow tell Mathematica to look for packages in other directories (like DropBox)? Basically, I have two computers running Mathematica -- one at home, and one at work, and would like to be able to work on editing/running my packages on both computers. • Adding the path to your local dropbox folder (or subfolder where you have stored the packages) does not work? reference.wolfram.com/mathematica/ref/$Path.html – Peltio Oct 28 '13 at 22:16
• Ok, I tried it, and that works! but only for one time. $Path gets reset every time I open Mathematica, so I need something more permanent. – QuantumDot Oct 29 '13 at 7:53 • Ok, the answer to my second question is here: mathematica.stackexchange.com/questions/1874/… – QuantumDot Oct 29 '13 at 7:58 • @Peltio Please put your response as an answer so I can accept it. (Please add a few words about making changes to$Path permanent). – QuantumDot Oct 29 '13 at 7:59

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...

• Something went wrong when trying to associate links with $namedvariables. I had to add the links in a separate manner. – Peltio Oct 29 '13 at 13:58 • I fixed them for you. They didn't work because the markdown link syntax was incorrect. Links are entered as [link text](url) and url must have http(s):// – rm -rf Oct 29 '13 at 16:00 • Thanks. Every day I learn something new. :-) – Peltio Oct 29 '13 at 16:04 • Because you use AppendTo rather than Append you don't need$Path =. – Stephen Luttrell Oct 29 '13 at 17:54
• Right, I edited the post to reflect this. – Peltio Oct 29 '13 at 18:15

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:

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.