Sublime Forum

How to handle user settings file and dynamic context menu


Hi everyone

I have 2 stupids issues and I absolutely have no clue at all.

First, it’s about the file :
• why on github, the md file displays correctly, especially the screenshots hosted directly on my repo ( And on Package Control, it displays weirdly without the screenshots ( ? I noticed that the screnshots link are all replaced with a wrong url…

Secondly, and it’s more tricky for me, because I just do not understand (it’s my first plugin, and also my first code written in python)…

I noticed lately that my ST3 plugin is on Package Control, so I decided to install from Package Control to test it.

But after installing, I got those 2 errors :
• error: The settings file “res://Packages/regex_portfolio/RegexPortfolio.sublime-settings” could not be opened
• FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\miki\AppData\Roaming\Sublime Text 3\Packages\Regex Portfolio\Context.sublime-menu’

How a same code, installed manually (by cloning github) works “correctly” and installed throught Package Control could have 2 differents behaviour?

It’s only a tiny plugin, nothing extraordinary like some I can see on Github/Package Control. But I still want to share =)

I reread my code and change it to

SETTINGS_FILE = 'RegexPortfolio.sublime-settings'
custom_settings = None

def regex_portfolio_settings():
   global custom_settings
   if custom_settings is None:
      custom_settings = sublime.load_settings(SETTINGS_FILE)

   return custom_settings.get(USER_REGEX_PORTFOLIO_KEY)

but not sure if it will work correctly or not through Package Control.

I guess that the problem is the same about the context menu file (written dynamically, based on the user settings)

Is there a way to test my plugin “as if” it was installed from Package Control?

Thank you for reading




The name of the folder in the Packages folder is the name of the package itself. If you clone the repository manually, you end up with a package named regex_portfolio. However the entry in the Package Control Channel File says that the package is named Regex Portfolio.

Those aren’t the same thing.

In the sublime-commands file, the command entry for editing the settings file is laid out like this:

    "caption": "Regex Portfolio: manage My Regex",
    "command": "edit_settings",
    "args": {
      "base_file": "${packages}/regex_portfolio/RegexPortfolio.sublime-settings",
      "default": "// Copy/Paste the user Regex Portfolio template from the left panel into here \"RegexPortfolio.sublime-settings\"\n\n{\n\t$0\n}\n"

The base file ${packages}/regex_portfolio is saying that the file to open is stored in a package named regex_portfolio; so it works when you clone the repository manually, but not when it’s installed by Package Control because in that case the package name is different.

All else being equal you should name your repository the same as you expect the name to be publicly exposed via Package Control, and then make sure that the entry in the channel file matches the name.

Correct; it’s also presuming that the package is named something that it’s not, depending on which way you installed it.

The Package Control: Add Repository command in the command palette can be used to give Package Control your GitHub repository URL. Once you do that, you should be able to use Package Control: Install Package to get PC to install the package directly from your repository. Be careful not to do this when you have your code checked out into the packages folder though; it may be best to move that away or use a portable version of Sublime instead.

I’m not sure offhand why Package Control would rewrite the URL’s like this, but most people that link to screenshots link to the version of the file at, so that may be a thing to try.

For your case, that would be instead; that may work better for you.



Thank you for your time and reply =)
I obviously misread a lot of things…
I will do the corrections based on your advices




I followed your instructions and it seems that it works well now =)

I renamed my Repo, and changed my context menu to work directly from the cache directory

Just made a PR on Package Control

Thank you again