Sublime Forum

[SOLVED] avoid "access is denied" when trying to write cache

#1

I try to develop my package on Windows and ST3.
My package need to write a cache file but whenever I tried to makedirs or open file to write by ‘open’, it does not work, with the error information in Ctrl+` :

Traceback (most recent call last):
File “C:\Program Files\Sublime Text 3\sublime_plugin.py”, line 74, in reload_plugin
m = importlib.import_module(modulename)
File “./importlib/init.py”, line 90, in import_module
File “”, line 1584, in _gcd_import
File “”, line 1565, in _find_and_load
File “”, line 1532, in _find_and_load_unlocked
File “C:\Program Files\Sublime Text 3\sublime_plugin.py”, line 678, in load_module
exec(compile(source, source_path, ‘exec’), mod.dict)
File " in C:\Users<User>\AppData\Roaming\Sublime Text 3\Packages<packagename><packagename>.py", line 18, in (*)
File “./os.py”, line 269, in makedirs
PermissionError: [WinError 5] Access is denied.: ‘’

(*) where in the line 18 I try to make dirs with os.makedirs(path) under the same location (.\Packages<packagename>)

So is the problem when I try to write cache under the same path(error info: “FileNotFoundError: [Errno 2] No such file or directory: \cache”)

Everything becomes right when I save something to that path. It seems that I can get the permission to write that path by doing some change to that path with ST open. But whenever I close ST window and restart it, the problem comes back.

One of my friends said the same problem comes up in Mac OS.

Is there anyone who tried to write cache in their package and know how to write cache properly?

Thank you!


I found the problem myself. I get sublime.packages_path() when importing, which results in the error path.

0 Likes