Sublime Forum

[solved] Plugins install require admin priviledge

#1

Hello,
Everytime I try to install a plugin, an error as below show, and I must restart sublime text as administrator to install it. I use a portable version, and the problem is obvious, it’s priviledge related, but I don’t know what to do to solve it. Please help.

Exception in thread Thread-188:

Traceback (most recent call last):
File “./python3.3/threading.py”, line 901, in _bootstrap_inner
File “D:\PortableSoftware\SublimeText3\Data\Installed Packages\Package Control.sublime-package\package_control/package_installer.py”, line 202, in run
self.result = self.manager.install_package(self.package)
File “D:\PortableSoftware\SublimeText3\Data\Installed Packages\Package Control.sublime-package\package_control/package_manager.py”, line 1288, in install_package
os.chdir(package_dir)
PermissionError: [WinError 5] Access denied.: ‘c:\windows\temp\tmp4lweqh\working’

0 Likes

#2

I’m not a Windows guru, but I think the temp folder inside of the Windows folder is supposed to be for system use and your user temp folder should be stored somewhere under AppData\Local in your home directory (i.e. every user should have their own unique temp folder).

If that’s the case, perhaps it’s going pear shaped because it’s picking a temp folder that it doesn’t have access to.

Do you have any environment variables set up that are changing the temp directory to somewhere else?

2 Likes

#3

Hi, thank you for your help.

I check the user env vars and yes the TEMP and TMP item were both set to %SystemRoot%\TEMP, I changed them to %USERPROFILE%\AppData\Local\TEMP. Then I start sublime text, when I try to install a plugin, the error message is still there.

To make sure the new env var is in use, I open explorer and input %temp% in the address bar, it open the %USERPROFILE%\AppData\Local\TEMP path.

It seems sublime text use another var. So I check the error message and locatate the related file, Data\Installed Packages\Package Control.sublime-package\package_control/package_manager.py, and find it’s the tempfile package which cause this. I run the related code in console, and the error can be reproduced. So maybe PackageControl should do an upgrade to solve this.

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> tmp_dir = tempfile.mkdtemp(u'')
>>> print(tmp_dir)
c:\windows\temp\tmptagljs
>>> import os
>>> tmp_working_dir = os.path.join(tmp_dir, 'working')
>>> os.mkdir(tmp_working_dir)
>>> package_dir = tmp_working_dir
>>> os.chdir(package_dir)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 5] : u'c:\\windows\\temp\\tmptagljs\\working'
>>> os.chdir(tmp_dir)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 5] : u'c:\\windows\\temp\\tmptagljs'
>>> exit()
0 Likes

#4

I made a test in console, and yes the $tmp/$temp var matters. But how to make sublime text works fine?

sf@sfss MSYS ~
$ tmp=$USERPROFILE\\AppData\\Local\\TEMP

sf@sfss MSYS ~
$ temp=$USERPROFILE\\AppData\\Local\\TEMP

sf@sfss MSYS ~
$ wpy
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> tmp_dir = tempfile.mkdtemp(u'')
>>> print(tmp_dir)
c:\users\sf\appdata\local\temp\tmpkqwbj1
>>> import os
>>> tmp_working_dir = os.path.join(tmp_dir, 'working')
>>> os.mkdir(tmp_working_dir)
>>> package_dir = tmp_working_dir
>>> os.chdir(package_dir)
>>> exit()
0 Likes

#5

I finally solved the problem after a reboot, Thanks for your help!

1 Like