Sublime Forum

Extract packages

#1

Hi,

I recently realized you can extract .sublime-package files
from Data/Installed Packages/MySublimePackage.sublime-package
to Data/Packages/MySublimePackage/
(Turned out there is also a package doing this: https://github.com/SublimeText/ExtractSublimePackage).

Is this a core Sublime Text feature?
Will everything work as expected when I extract .sublime-packages?
Package updates will happen in the extracted folder?

Thanks,
Norbert

0 Likes

#2

Indeed it is a core feature of Sublime that files from Packages/SomePackage are considered to be a part of the same package in Installed Packages/SomePackage.sublime-package, yes. This allows you to make modifications to the content of a sublime-package file without modifying the file directly.

This is important because when Sublime and Package Control upgrade packages that are stored as sublime-package files, they replace the old file with a new one. Hence if you put your changes inside of a sublime-package file, they will be lost.

The package will continue to work if it’s extracted, if that’s what you mean. I wouldn’t say that everything will work as expected, though (see below).

No, if a package is installed as a sublime-package file, then whatever installed it will upgrade the sublime-package file when things need to be upgraded. As mentioned above, this will remove the old sublime-package file and replace it with a new one.

However, when Sublime loads packages, if there is a file in Packages/SomePackage and also a file with the same name in SomePackage.sublime-package, then the one in the Packages folder is loaded instead (this is referred to as an override).

This allows you to modify the content of a package, because as noted above when packages are upgraded, the entire sublime-package file is replaced. So if you put your changes inside the sublime-package file, they will be lost. If they’re in Packages/SomePackage, they will remain in effect.

Since Sublime will always load files from the Packages folder in this case, extracting a package will forever lock that package at whatever version it was at when you extracted it. If the package updates, a new sublime-package will be put in place, but Sublime will ignore the files inside of it in place of the ones that are unpacked.

If the installed sublime-package also adds additional files that were not previously there, those files would be seen (because they don’t exist in the Packages folder), which could cause problems as well.

This is all a really long winded way of saying:

Yes, you can extract a package if you want to. However there are not really many compelling reasons to do so, it’s fairly dangerous and likely to lead to frustration down the line and thus probably not recommended unless you have a really specific reason to do it (and possibly not even then).

1 Like

#3

Thank you very much for the detailed answer :slight_smile:

0 Likes