Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Adding the path to your local dropbox folder (or subfolder where you have stored the packages) does not work?$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:… – 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
up vote 9 down vote accepted

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

share|improve this answer
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):// – R. M. 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:


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.

Finder Image

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.

share|improve this answer

I assume this would also serve the purpose?

share|improve this answer
I'm afraid you may have misunderstood FindFile. FindFile searched for a file exactly the same way as Get, but instead of loading the file, it just returns the complete path. This is useful e.g. when you need to find out which of two identically named files would be loaded by Get/Needs, or if you just need the full path for any reason. So Get[FindFile[something]] will always be equivalent to Get[something]. If the latter doesn't work, neither does the former. – Szabolcs Jan 20 '14 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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