[Tex/LaTex] Changing the location of auto-installed packages in MiKTeX

installingmiktex

This is a software question, specific to MiKTeX: I have automatic downloading of packages enabled, so that if I try to use a style that's not in the existing directory trees, it is downloaded from CTAN and installed. The problem is that MiKTeX installs it under %APPDATA% (at C:\Documents and Settings\<user>\Application Data\MiKTeX\2.9), which bloats my roaming profile. Is there a way to change this destination?

I already have another root for styles I install myself, but I can't get MiKTeX to use it for auto-installed packages. In the Roots list in MiKTeX Settings (mo.exe), the %APPDATA% folder has the tag "UserInstall". It won't let me edit or delete its path, or tag another root "UserInstall". Is there a way to do this, or am I stuck with rearranging the downloaded packages by hand afterwards?

Best Answer

As Ulrike explained in the comments above, it seems that MikTeX allows the UserInstall directory to be configured only during installation. So, it's easiest to just re-install it, calling the installer from the commandline with suitable options. The full set of commandline options for the installer is documented here.

I first removed the existing MikTeX by running the uninstaller from the Start menu. I then opened a command prompt (this is on Windows), switched to the directory containing the downloaded installer, and ran the following:

C:\...> basic-miktex-***.exe --shared --user-install="C:\Path\to\my\root"

I used --shared since it's being installed for all users, but I was asked again during the set-up dialog anyway. There are also options --user-config and --user-data (I don't mind leaving those in the default location).

I am just setting up a new computer, so this was a no-brainer. I follow best practices and keep all style files that are not managed by MikTeX in a separate texmf hierarchy, so there was no need to salvage anything before uninstalling. But if you have been dropping your non-CTAN styles into the MikTeX texmf tree (definitely not a good idea), or have a huge texmf tree and a slow internet connection, or use your computer off-line a lot and don't want to be surprised by missing packages, you can follow this procedure, which lets you use your old texmf tree as the data source for the new installation (thanks @Speravir for the pointer).

Related Question