33. Dual Boot Setups

Some day (maybe now) you may want to run Sublime Text in two different operating systems on the same computer, for example Windows and Linux, while making both versions of Sublime Text share the same data directory. There is a workable way to do this.

Assuming your “master” Sublime Text data directory is under Windows, you can choose to either have the Linux OS use the data directory where it is, or you can choose to move it to a storage location that both OSes can share. The only restriction is that you would not be able to safely run Sublime Text on both OSes at the same time. Assuming that is the case, read on to find out how.

33.1. The Windows Side

If you chose to have Sublime Text on the Linux side access the data directory where it is on the Windows system without moving it, there is nothing further to do on the Windows side of things. You can skip to The Linux Side.

If you chose to move the Sublime Text data directory to a shared location, follow these steps on Windows to do so.

  • Close Sublime Text on the Windows system.

  • Manually move the directory (typically %APPDATA%/Sublime Text/) to the shared location. For illustration, let’s say it is:

    E:\System\sublime_data\
    
  • In its place, create a Directory Junction:

    c:
    cd %APPDATA%
    mklink /J  "Sublime Text"  E:\System\sublime_data
    
  • Using File explorer, navigate to %APPDATA%/Sublime Text/ and ensure you see your Sublime Text data files. It should contain at least these directories:

    • Installed Packages/ (if you have installed any 3rd-party Packages)

    • Lib/

    • Local/

    • Log/

    • Packages/User/

    • Packages/... (any other packages you may be developing or have overrides for)

    and possibly also:

    • Backup/ and

    • Trash/

  • Start Sublime Text, and ensure you are able to run any custom Commands you may have created in your User Package, and Packages you have installed run correctly.

    If you have a Sublime Text license, look at the title bar and ensure it does not say “Unregistered”.

33.2. The Linux Side

33.2.1. Getting Sublime Text

To avoid confusion and any potential problems, ensure that you are using the same version on both platforms.

On Ubuntu, Linux Mint, and other Linux distributions that use the apt package manager:

  • Install the GPG key:

    wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo tee /etc/apt/keyrings/sublimehq-pub.asc > /dev/null
    
  • Select the channel to use:

    • Stable

      echo -e 'Types: deb\nURIs: https://download.sublimetext.com/\nSuites: apt/stable/\nSigned-By: /etc/apt/keyrings/sublimehq-pub.asc' | sudo tee /etc/apt/sources.list.d/sublime-text.sources
      
    • Dev

      echo -e 'Types: deb\nURIs: https://download.sublimetext.com/\nSuites: apt/dev/\nSigned-By: /etc/apt/keyrings/sublimehq-pub.asc' | sudo tee /etc/apt/sources.list.d/sublime-text.sources
      
  • Update apt sources and install Sublime Text:

    sudo apt-get update
    sudo apt-get install sublime-text
    

If that doesn’t work, or if you have a system that uses a different package manager, follow the instructions at Linux Package Manager Repositories.

33.2.2. Paths

On the Linux side, you can actually share project files with the Sublime Text on Windows by mounting the windows drives to mount points that use their drive latter under Windows.

Example: say you have a project with a path:

"path": "E:\\System\\sublime_data\\Packages",

or

"path": "E:/System/sublime_data/Packages",

Under Linux, if you mount that drive to mount point /e, then Sublime Text on both sides can share project files by re-writing the path above like this:

"path": "/e/System/sublime_data/Packages",

Sublime Text under Windows is just as happy with the last version of that path as the first two.

33.2.3. Data Directory

Under Linux, the path to the Sublime Text data directory is

~/.config/sublime-text/

To get Sublime Text on Linux to use the shared directory you created above (or the original path to the Windows Sublime Text data directory), do the following:

  • Close Sublime Text on Linux

  • Execute these commands:

    $ cd ~/.config
    $ # Preserve original directory in case there is something valuable in it.
    $ mv ./sublime-text ./sublime-text.orig
    $ # In its place, create a symbolic link to the new shared directory.
    $ ln -s  /path/to/shared/data/directory  ~/.config/sublime-text
    
  • Navigate to the symbolic link and ensure the files in the Windows Sublime Text data directory are present.

  • Start Sublime Text and observe:

33.2.4. Cross-Platform Conflicts

If you have any Packages that do not load correctly under Linux, you have the option of using

my_platform = sublime.platform()

and thereafter my_platform will contain one of these values:

  • ‘windows’

  • ‘linux’

  • ‘osx’

in order to determine what things need to be re-coded to be compatible on both platforms.

33.3. License

Assuming you have paid the deserving development team at Sublime Text HQ for the honor of continuing to use Sublime Text, you will have a license file in the Sublime Text data directory in the ./Local/ subdirectory.

According to Portable License Keys, when you copy/paste your license into the window that prompts for it,

“Sublime Text stores license keys in a format specific to the computer it’s entered on.”

Unfortunately, this is not completely accurate, and probably should read:

“Sublime Text stores license keys in a format specific to the computer and platform it’s entered on.”

However, according to that same documentation page, there is a work-around for a situation involving the Portable version of Sublime Text—which this is not—but it happens to work for this issue as well. I quote from that documentation page:

“This can be worked around by manually saving the license key as plain text, which Sublime Text will read from, but not write to.”

Here are the steps to take to implement this work-around:

  • Close Sublime Text.

  • Create a new text file in the data directory ./Local/ subdirectory.

  • Paste into it the plaintext version of your license key. This should be its only contents.

  • Remove or move the original License.sublime_license to a safe place if you wish to preserve it. (It can always be re-generated if need be.)

  • Rename the text file you just created to License.sublime_license.

  • Re-start Sublime Text.