Sublime Forum

Reinstalling ST at current version while keeping packages?

#1

Hi,

I was trying to edit the Celeste color scheme, but not finding the .tmTheme file. In a fit of desparation I did these two things, which in combination have broken my installation of Sublime:

  1. Opened Packages/Color Scheme - Default.sublime-package and, when prompted with the dialog box Extract Color Scheme - Default.sublime-package to the Packages directory? I answered “yes”. (Nb: After switching the encoding to UTF-8 I did find a section named “Celeste” in that file. Editing it seemed to have no effect on the editor, though.)

  2. Ran PackageResourceViewer: Extract All Packages. (FYI, PackageControl subsequently complained of finding itself in two places at once. It asked me to delete its extracted doppelgänger, which I did.)

After these brilliant moves, I restarted ST3, at which point ST3 complained that it couldn’t find Celeste at all. Also gone were: Breakers, Sixteen, Mariana. (Monokai survived. I don’t know why, but Monokai also happens to be the only theme that was showing up in the Packages/Color Scheme - Default folder before I did any of this.)

Now I guess my best bet is to reinstall ST3. I’m already at the latest version though. Is there an easy command for doing a non-update reinstall? I find it kind of scary to entirely delete ST3, or something like that…

PS: My issue is maybe that I corrupted the Color Scheme - Default.sublime-package file while editing it. If anyone has a current MacOS version of this file, sending it to me (upload it to pastebin?) might be enough to get me restarted…

0 Likes

#2

TL;DR version

Reinstalling Sublime has no effect on the packages that you have manually installed because all of your customizations to Sublime (including packages that you install yourself) are stored in a folder in your home directory.

Based on your problem description, the steps you want are something like the following:

  1. Use Sublime Text > Preferences > Browse Packages... from the menu to open the Packages folder, then copy everything out of it into another location to make a backup.
  2. Quit Sublime Text, then delete everything but the User package from the Packages folder
  3. Delete Sublime Text.app and reinstall Sublime
  4. Start Sublime Text

What this is going to do is make sure that anything that you might have done inside of the Sublime Text.app directory is undone. This is safe because this directory has “no user-serviceable parts inside”; all of your customizations happen in the Packages folder because this folder is replaced when you upgrade Sublime (and is why reinstalling Sublime when you’re having problems rarely has any effect).

Secondly, the User package is where all of your customizations to Sublime are kept (preferences, key bindings, etc). One of the things stored here is the Package Control settings file, which contains the list of packages that you’ve installed via PC. PC will automatically reinstall any packages that might be missing due to #2 above as well as their dependencies (if any). Most packages are installed as sublime-package files, so likely not too many are missing.

That should get you back into a fairly clean state. If you had any packages that you installed manually, you can pull their folders out of the backup you made in step #1 and put them back into the Packages folder. Most of the contents of your backup is the extracted contents of packages that you don’t want (which is why it’s easier to remove them all wholesale and have PC put what should be there back rather than trying to clean it up manually).

If you had any overrides that you created yourself, you will need to pull those individual files out of the backup and put them back in their respective packages to put the override back in place.


Longer “What Happened?!” version

For background, packages in Sublime can exist in three different places:

  1. Inside the folder named Packages, as folders where the name of the folder is the name of the package. You can use Preferences > Browse Packages to find this location.

  2. Inside of a folder named Installed Packages, which is a sibling of the above folder, and in this folder packages are sublime-package files (zip files with a changed extension).

  3. Inside of a folder named Packages in the location where Sublime Text is installed. These are Shipped Packages because they ship with Sublime (i.e. they’re common to everyone), and are also sublime-package files.

If a package is represented in more than one of these places at once, you have what is called an override in place, which means that Sublime is going to ignore one file and use the other.

  1. If a sublime-package appears in the Shipped location and in the Installed Packages folder, the shipped version is ignored and Sublime pretends that it doesn’t exist and uses the other one instead. Doing this is pretty rare.

  2. If a folder appears in the Packages folder, any files in it are considered as part of the sublime-package file with the same name but if any files in the folder have the same name as a file in the sublime-package file, Sublime will use that file and ignore the one in the sublime-package file.

This mechanism is the way you modify files in a package, because sublime-package files are replaced completely when they are upgraded, which would remove any changes that you might make to them directly.

Also worth noting that when you have overrides in place like this, Sublime uses them with no warning, including if the sublime-package file gets updated.

The default color schemes are Shipped packages, so it sounds like you did this in the Packages folder in the Sublime install folder. Sublime only loads sublime-package files from that folder, so any other files are ignored. You can safely remove anything inside of that folder that’s not a sublime-package file; they’re not doing anything.

This particular package command is one of the most destructive things you can do to your Sublime Text installation, and I’m surprised that it hasn’t been removed from the package or at least doesn’t have some sort of warning confirmation. I generally keep an override in place that removes it from the command palette to make sure that I don’t trigger it accidentally.

The reason is that it extracts every file from every sublime-package file into a folder in the Packages folder. From the background above, this means that by doing this you immediately create an override on every file in every package.

Since Sublime loads those files in preference to the ones inside of the sublime-package version, all updates to your packages are now effectively blocked in perpetuity, without warning, and is why Package Control warns you if it’s installed in two places at once.

Cleaning that up is a bit of a mess because some packages are always installed unpacked in the Packages folder while others are installed as sublime-package files instead. Package Control installs dependencies for your packages as folders in the Packages folder, and you might have a couple of overrides that you made on purpose.

Now’s the point where you skip up to the top of this long post to see the steps to take in order to resolve the problem and put things back as they were because this thing is pretty long as it is.

1 Like

#3

I could follow most of your post except for that paragraph :blush: Why “but”? It sounds like the two parts of the statement are saying the same thing. (I’m assuming you mean a .sublime-package file that’s in Installed Packages, or possibly in Sublime Text.app/.../Packages?)

0 Likes

#4

That’s just to drive home the idea that similarly named files are replacements and not additions to what’s contained in the package, while other files are indeed additions.

Yep, that’s correct.

0 Likes

#5

Also, if you are doing this just for yourself (not for redistribution), I highly recommend installing the PackageDev package and using its “Edit current color scheme” command. This will make a Packages/User/Celeste.sublime-color-scheme file in which to put your tweaks to the base version. From there you can override specific properties and add your own new properties.

1 Like