You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Loading plugins from "Installed Packages" archives fails when a directory with the same name exists in "Packages".
Steps to reproduce
Create a "TestPackage.sublime-package" zip archive with a Python plugin file named "test.py" with the following content:
print("testing")
Place this package into your "Installed Packages" dir and restart ST. You will find the following in the console:
reloading plugin TestPackage.test
testing
Now, go to your "Packages" dir and create a folder named "TestPackage". When restarting ST you will find the following:
reloading plugin TestPackage.test
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3 Portable Beta\sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1522, in _find_and_load_unlocked
ImportError: No module named 'TestPackage.test'
Expected behaviour
"test.py" loads successfully and prints "testing" when the module is not overridden. I know that the Packages dir is supposed to override the Installed Packages but it should only override those (files) if they actually exist.
Note: This is gonna get complicated when plugins are importing modules relative from their dir. Would it be possible to replace certain modules only in this situation?
This requires a few workarounds but I also decided to assume that "Package/..."
paths are the only accepted for color schemes. This should very rarely result
in issues if at all and simplifies the path math a lot.
Furthermore, work around a bug in ST which prevents me from creating a dir
named `module_path` in the Packages dir. See sublimehq/sublime_text#55.
As of 3043 the particular error in this issue has been fixed (loading modules when a folder with an installed package's name exists fails) but overriding installed packages is still not working that great.
For instance (assuming the same file structure as above):
Create a file named Packages/TestPackage/test.py and put something like print("not testing") in it. Console after restarting/saving:
reloading plugin TestPackage.test
testing
Create a file named Packages/TestPackage/test2.py and enter something like print("testing again") (contents don't matter). Console after restarting/saving:
reloading plugin TestPackage.test2
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3 Portable Beta\sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1522, in _find_and_load_unlocked
ImportError: No module named 'TestPackage.test2'
New issue?
I actually wanted to test this but due to the above error it wouldn't work: Can I import moduels from installed packages from the same "uninstalled" package? E.g., would from . import test work in test2.py?
The above concerns have been fixed with 3045 and another bug in 3046, marking this as fixed. Read the forum thread linked in the first post for more information
Loading plugins from "Installed Packages" archives fails when a directory with the same name exists in "Packages".
Steps to reproduce
Create a "TestPackage.sublime-package" zip archive with a Python plugin file named "test.py" with the following content:
Place this package into your "Installed Packages" dir and restart ST. You will find the following in the console:
Now, go to your "Packages" dir and create a folder named "TestPackage". When restarting ST you will find the following:
Expected behaviour
"test.py" loads successfully and prints "testing" when the module is not overridden. I know that the Packages dir is supposed to override the Installed Packages but it should only override those (files) if they actually exist.
Note: This is gonna get complicated when plugins are importing modules relative from their dir. Would it be possible to replace certain modules only in this situation?
Tested on Windows 7x64 with ST3 3035 Portable.
Forum link: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=12564
The text was updated successfully, but these errors were encountered: