7

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?

Speravir
  • 19,491
alexis
  • 7,961

3 Answers3

8

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

alexis
  • 7,961
1

As opposed to what the accepted answer says, it not "easier" to reinstall. One can make a simple edit in the registry: the install dir for packages is set on HKEY_LOCAL_MACHINE\SOFTWARE\MiKTeX.org\MiKTeX\2.9\Core\UserInstall

  • Good information, thanks! This would definitely be the way to go for an older installation (for which wiping and recreating would trigger unnecessary downloads, and possibly incompatibilities). For completeness: The registry is edited by running regedit from the CMD prompt, right? – alexis Jan 24 '16 at 13:04
  • 1
    Yes, with an administrator account. – Martin Argerami Jan 24 '16 at 13:57
  • Riight, administrator account. Forgot about all that. Not sure what happens on a roaming profile in a University environment (my use case), where I have limited admin rights. But fortunately, I don't personally need to try this anymore. :-) – alexis Jan 24 '16 at 14:52
  • There's no UserInstall in the Registry on my PC (Win 10, MiKTeX 2.9) – Arnaud Feb 17 '17 at 16:50
  • UserInstall might not be present in HKEY_CURRENT_USER, but might be in HKEY_LOCAL_MACHINE – Aidan Connelly May 22 '20 at 15:37
  • UserInstall in HKEY_LOCAL_MACHINE cannot (and should not) be edited by non-privileged users of shared workstations. – alexis Jun 24 '22 at 09:11
0

I solved by executing the installer from cmd prompt as portable installation:

basic-miktex-21.12-x64.exe --private --auto-install=yes --paper-size=A4 --portable=<destination-dir>

and add the <destination-dir>\install\miktex\bin\x64 folder manually to HKCU:\Environment\Path

Tobi
  • 1
  • So you just install a local "portable" Miktex, and of course packages are installed there too. That's good when it's sufficient, but it's not much help in a setup where Miktex is already installed on university computers, and I sit on a different computer every time. – alexis Jun 24 '22 at 09:09