The load_resource() function fails loading resources from a sub directory of a package, when called directly in plugin_loaded() hook, while package is being enabled.
Steps to reproduce
Start ST in SAFE MODE
Create a Package named "Debug" in Data (Safe Mode)/Packages
Add a child folder "py33" in "Debug".
Add an empty "debug.json" with only an object {} in it.
All resources of a package should be available and accessible in plugin_loaded() function.
Actual behavior
load_resource() thows FileNotFoundError on python 3.8 or OSError on python 3.3 plugin_host, if the resource to load is located in a sub directory of the package.
reloading python 3.3 plugin Debug.debug
Traceback (most recent call last):
File "C:\Apps\Sublime Text 40xx\Lib\python33\sublime_plugin.py", line 400, in load_module
m.plugin_loaded()
File "C:\Apps\Sublime Text 40xx\Data (Safe Mode)\Packages\Debug\debug.py", line 4, in plugin_loaded
sublime.load_resource("Packages/Debug/py33/debug.json")
File "C:\Apps\Sublime Text 40xx\Lib\python33\sublime.py", line 435, in load_resource
raise IOError('resource "%s" not found' % name)
OSError: resource "Packages/Debug/py33/debug.json" not found
It happens if the package is removed from "ignored_packages" list.
It does not happen when reloading happens due to saving/modifying the file.
Note: This issue can/must currently be worked around by calling any function which makes use of load_resource() via sublime.set_timeout().
I face the same issue using sublime.find_resources in CommandsBrowser. I worked around it using the aliter described, calling it in sublime.set_timeout
Description of the bug
The
load_resource()
function fails loading resources from a sub directory of a package, when called directly inplugin_loaded()
hook, while package is being enabled.Steps to reproduce
{}
in it.Add a plugin named "debug.py" in root of "Debug"
"ignored_packages"
Expected behavior
All resources of a package should be available and accessible in
plugin_loaded()
function.Actual behavior
load_resource()
thowsFileNotFoundError
on python 3.8 orOSError
on python 3.3 plugin_host, if the resource to load is located in a sub directory of the package.It happens if the package is removed from
"ignored_packages"
list.It does not happen when reloading happens due to saving/modifying the file.
Note: This issue can/must currently be worked around by calling any function which makes use of
load_resource()
viasublime.set_timeout()
.Sublime Text build number
4134
Operating system & version
Windows
(Linux) Desktop environment and/or window manager
No response
Additional information
No response
OpenGL context information
No response