Sublime Forum

Why Does My Sublime Plugin Work in Dev Mode But Fail When Installed as a Package?

#1

Hello

I have been working on a custom Sublime Text plugin that extends the functionality of the sidebar context menu to include some batch renaming features. :innocent:When I run the plugin in my local Packages/User/ directory; everything works perfectly. However; when I zip it up and install it via Package Control / place it in the Installed Packages folder, certain features especially file operations either throw silent errors / don’t execute at all.:expressionless:

I have checked for basic issues like folder structure;plugin_loaded() & dependency loading. It seems like file path resolution / package scoping behaves differently when the plugin is not in development mode. :innocent:I am curious: are there hidden sandboxing / permission nuances when Sublime loads a plugin as a .sublime-package archive?:thinking:

I have checked https://docs.sublimetext.io/guide/extensibility/plugins/ guide for reference . While exploring automation concepts similar to uipath. I wondered if similar task automation could be integrated into Sublime plugins.:innocent:

Would love guidance from experienced plugin developers on how to debug this scenario. Maybe there’s a best practice for logging errors inside compressed plugin packages / using sublime.executable_path() for dynamic path fixes?:thinking:

Thank you!!:slightly_smiling_face:

0 Likes

#2

Generally speaking, plugins work the same whether they are loose files (Unpacked) or packages (inside sublime-package files).

Files inside of the Packages folder are treated as a virtual file system; if you use View Package File you will see all package files that are available, prefixed via their package name as a path (not counting all of the sublime-package files that appear in the list). So from this perspective, there is no difference.

That said, there are a couple of things that might catch you unawares:

  • If your plugin tries to load or otherwise access any file that exists inside of Packages/ (such as loading a file of some sort) by way of using sublime.packages_path() to find the location of the file, that will fail when you’re packaged up because those files don’t exist (they’re in the sublime-package); if you need to do this, use sublime.load_resource() to load the file, which always works no matter what

  • If your plugin works in User but doesn’t work in other packages, you may be running afoul of the fact that plugins in your User package always run in the Python 3.8 plugin host, but by default every other package runs in Python 3.3, unless you specificaly tell Sublime they should be in the newer host (https://www.sublimetext.com/docs/api_environments.html)

Failing this you would need to be more specific of what problems you’re actually seeing.

0 Likes