Sublime Forum

Relocating the "data" directory

#1

ST has its “data” directory located as described here:

https://www.sublimetext.com/docs/3/revert.html

and here:

http://docs.sublimetext.info/en/latest/basic_concepts.html#the-data-directory

I am looking for a way to put this directory in another location.

A straight forward solution would have been an environment variable (e.g. SUBLIME_TEXT_DATA), which could be set to the path of the new location. This would work at least on Windows and Linux (I am unfamiliar with OS X). However, I have not seen this mentioned anywhere.

I would prefer not using symlinks, as this functionality may be unavailable on certain file systems.

Is there a way to tell ST where to look for its “data” directory?

2 Likes

#2

No, but you can use the portable version, whereby the data directory is just a subfolder of where-ever you place the portable version.

0 Likes

#3

I do use the portable version. Then, every time I install a new ST realease, I have to copy the “data” directory over from the old release. I was hoping there would be a way to avoid this.

0 Likes

#4
  1. Quit Sublime Text
  2. Copy those folders into location that you need.
  3. Remove those folders.
  4. Create a symbolic link to the new location.
  5. Done.

There is no other way.

0 Likes

#5

Unfortunately, I cannot use symlinks on Windows, because I have no administrative rights on the computer. This also would not work if ST was installed on a FAT32 file system.

How does ST find the location of the “data” directory on Windows?

From the documentation it would seem to use the APPDATA environment variable. If that was the case, setting it to a different location before starting ST should put the “data” directory there. That does not seem to work.

0 Likes

#6

You can use a directory junction without admin rights. Also, it’s probably enough to keep your User folder linked in this way instead of all of Data.

To create a directory junction: c:\ mklink /J LINK TARGET.

Note that after you do this, Sublime Text will stop auto-detecting changes to config files, etc. You will need to restart the application to refresh changes to config files.

0 Likes

#7
2 Likes

#8

Unfortunately, junctions only work on local NTFS volumes. In this case I am trying to put the “data” directory on a mapped network share.

Also, if having ST installed on a USB stick (FAT32), it would be nice to have the “data” directory separated from the program but still located on the stick. Junctions/symlinks could not be used there.

0 Likes

#9

A bit of information for those interested. :slightly_smiling:

This only applies to ST on Windows:

As mentioned previously, ST does not seem to use the APPDATA environment variable when locating the “data” directory, even though the documentation says it should. It seems to use the USERPROFILE environment variable instead. Example:

If USERPROFILE is set to “C:\temp\ST” just before starting ST, the “data” directory will be put in “C:\temp\ST\AppData\Roaming\Sublime Text 3” and cache will be put in “C:\temp\ST\AppData\Local\Sublime Text 3”.

3 Likes

Move %APPDATA%\Sublime Text 3\Packages
#10

nice find! thanks for sharing :slight_smile:

0 Likes

#11

Hi - this would be of great benefit to my organization, which holds a business license.

We have a heavy Sublime user base so I have begun productionizing a Sublime project. I am not willing to drop arbitrary files in their ~/Library and our Sublime usage is 100% OSX so we cannot leverage the Windows relocatable install.

What would be ideal is an override to the default config directory on a global or per-project basis. This could be through a Sublime-specific project setting, an environmental variable, or usage of the XDG envs, e.g. XDG_CONFIG_HOME.

0 Likes

#12

It is theoretically possible to swap the Data directory around on MacOS, although this is not documented and thus probably not officially supported.

If you create a Data directory inside of /Applications/Sublime Text.app/Contents/MacOS, Sublime will use that as it’s Data directory instead of the default, just as it will for Windows and Linux if you create such a directory in the appropriate place. This is how the Windows portable version works, but is only documented for Windows and not the other operating systems.

Some (minimal) testing shows that Sublime seems to follow symlinks in this case, allowing you to link that Data directory with the normal default or some other location entirely.

The down side of this (besides it not being officially documented, which I’m only harping on for safety reasons) is that it doesn’t net you a full solution as you mentioned above because you would need to quit Sublime and swap the link, so it can’t be project specific without manual intervention, which also stops you from being able to work on multiple projects at once.

2 Likes

Testing a package -- portable Sublime for Mac or Linux?