microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.25k stars 29.3k forks source link

EACCES permission error when trying to install extension (Mac OS High Sierra) #43993

Closed MartinP7r closed 5 years ago

MartinP7r commented 6 years ago

Error message: EACCES: permission denied, open '/var/folders/xq/8yrkk6xn1p9btfkhp6jdgckdpx3v2_/T/a56e830b-0d87-4be8-9357-6b481661b2f8' with variable last folder name in path, but always in subfolder T (which apparently is the $TMPDIR on mac as I just found out)

logged in user has permissions on the folder in question:

a56e830b-0d87-4be8-9357-6b481661b2f8_info_and_extension__vetur_ _screenshot-log

Steps to Reproduce: not sure how to reproduce

Does this issue occur when all extensions are disabled?: Yes

MartinP7r commented 6 years ago

update: this seems to be only the case with the extension 'Vetur'
I'll post in its repository and leave a solution here as soon as I get one.

octref commented 6 years ago

@joaomoreno I found #41797 but the OP explicitly mentioned he has write access to temp dir.

joaomoreno commented 6 years ago

@cyrus86 What does ls -ld $TMPDIR return?

MartinP7r commented 6 years ago

It returns:

drwx------@ 22 USERNAME  DOMAINNAME\Domain Users  704 Feb 21 08:31 /var/folders/xq/8yrkk6xn1p9btfkhp6jdgckdpx3v2_/T/

USERNAME is the current logged in user, who also owns vscode when checked in the activity monitor. I deleted the contents of $TMPDIR several times already. Didn't change the outcome.
also posted to vetur repo: https://github.com/vuejs/vetur/issues/699

joaomoreno commented 6 years ago

How about ls -ld /var/folders/xq/8yrkk6xn1p9btfkhp6jdgckdpx3v2_/T/a56e830b-0d87-4be8-9357-6b481661b2f8?

MartinP7r commented 6 years ago

Ooooh -rw-r--r-- 1 USERNAME DOMAINNAME\Domain Users 24036189 Feb 22 10:04 //var/folders/xq/8yrkk6xn1p9btfkhp6jdgckdpx3v2_/T/69166665-12fc-4bb6-bef6-938c186e08a3
It seems that neither owner nor group have execute permission on it. That can't be normal, right?
So the temporary file is created without those permissions for Vetur only? Otherwise I wouldn't be able to install any other extensions, correct?

joaomoreno commented 6 years ago

I don't know who creates that folder. But since this seems to happen always with the vetur extension (#41797), I'd say it's either them or vetur itself. Please check with them to understand who creates that GUID folder.

octref commented 6 years ago

@sandy081

const zipPath = path.join(tmpdir(), generateUuid());

https://github.com/Microsoft/vscode/blob/master/src/vs/platform/extensionManagement/node/extensionGalleryService.ts#L482

joaomoreno commented 6 years ago

I just realised that that path isn't a folder. The permissions -rw-r--r-- look OK to me.

@cyrus86 Can you install any other extension? Does the issue reproduce all the time with the Vetur extension?

MartinP7r commented 6 years ago

I reproduces every time with the Vetur extension.
Other extensions I can install without problems, tried a couple since I realized the problem with Vetur.

joaomoreno commented 6 years ago

@sandy081 Any ideas?

sandy081 commented 6 years ago

@cyrus86 Can you please set log level to trace using command Set Log Level and open shared process logs using command Show Logs.. and show us the log?

MartinP7r commented 6 years ago

Hi @sandy081 , thank you for helping me out.
There's only main, shared, window and extension host under Show Logs..
Shared did show the following output when trying to install vetur:

[2018-02-27 08:06:20.786] [sharedprocess] [trace] Started scanning system extensions
[2018-02-27 08:06:20.786] [sharedprocess] [trace] Started scanning user extensions
[2018-02-27 08:06:20.786] [sharedprocess] [trace] Started scanning system extensions
[2018-02-27 08:06:20.786] [sharedprocess] [trace] Started scanning user extensions
[2018-02-27 08:06:20.786] [sharedprocess] [trace] Started scanning user extensions
[2018-02-27 08:06:20.862] [sharedprocess] [info] Scanned user extensions: 29
[2018-02-27 08:06:20.864] [sharedprocess] [info] Scanned user extensions: 29
[2018-02-27 08:06:20.870] [sharedprocess] [info] Scanned user extensions: 29
[2018-02-27 08:06:20.934] [sharedprocess] [info] Scanned system extensions: 65
[2018-02-27 08:06:20.939] [sharedprocess] [info] Scanned system extensions: 65
[2018-02-27 08:06:28.070] [sharedprocess] [info] Installing extension: vetur
[2018-02-27 08:06:28.071] [sharedprocess] [trace] Started downloading extension: vetur
[2018-02-27 08:06:30.315] [sharedprocess] [info] Downloaded extension: vetur
[2018-02-27 08:06:50.322] [sharedprocess] [trace] Started scanning system extensions
[2018-02-27 08:06:50.323] [sharedprocess] [trace] Started scanning user extensions
[2018-02-27 08:06:50.409] [sharedprocess] [info] Scanned user extensions: 29
[2018-02-27 08:06:50.426] [sharedprocess] [info] Scanned system extensions: 65
[2018-02-27 08:06:50.427] [sharedprocess] [error] Failed to install extension: octref.vetur EACCES: permission denied, open '/var/folders/xq/8yrkk6xn1p9btfkhp6jdgckdpx3v2_/T/38efa758-c842-4ac2-a9d8-0b91e3947ef7'
[2018-02-27 08:06:50.535] [sharedprocess] [trace] Started scanning system extensions
[2018-02-27 08:06:50.535] [sharedprocess] [trace] Started scanning user extensions
[2018-02-27 08:06:50.552] [sharedprocess] [trace] Started scanning system extensions
[2018-02-27 08:06:50.552] [sharedprocess] [trace] Started scanning user extensions
[2018-02-27 08:06:50.589] [sharedprocess] [info] Scanned user extensions: 29
[2018-02-27 08:06:50.625] [sharedprocess] [info] Scanned user extensions: 29
[2018-02-27 08:06:50.698] [sharedprocess] [info] Scanned system extensions: 65
[2018-02-27 08:06:50.709] [sharedprocess] [info] Scanned system extensions: 65

the other logs didn't really show any changes when installing vetur. let me know if you need them as well.

sandy081 commented 6 years ago

Assigning to February milestone for investigation

uroymyy commented 6 years ago

i've got the same problem when trying to install prettier-vscode

octref commented 6 years ago

@cyrus86 and @uroymyy

Are you both on High Sierra? Do you have FileVault on?

sandy081 commented 6 years ago

Logs do not have additional information.

Can you try downloading the extension directly from Market place ? Browse for the extension in market place and there will be a link to download extension under resource section on the right.

Also try to download it into the temp directory.

uroymyy commented 6 years ago

yes on High Sierra, i've downloaded the vsix file and installed it from the command line "code --install-extension ./Downloads/esbenp.prettier-vscode-1.2.2.vsix" works fine now... thanks

MartinP7r commented 6 years ago

Yes, High Sierra and no FileVault.
Installing the extension from the market place was successful, as well.

edit: when downloading it into the temp folder it is being created without execution rights for the owner, though. so i guess it's a problem with my setup after all. though I am stumped why it works for other extensions

$ lsa octref.vetur-0.11.7.vsix                                                                                        
-rw-r--r--@ 1 USER  staff    23M Mar  5 16:39 octref.vetur-0.11.7.vsix
sandy081 commented 6 years ago

No clue why it is working for other extensions. Can you open that temp folder and try to install an extension from VS Code and see if a folder is created in the temp folder?

MartinP7r commented 6 years ago

I tried and observed installing phpcs extension just now. It creates a temporary file just like above,

-rw-r--r--  1 USER  DOMAIN\Domain Users   691K Mar  7 08:05 60f9a38a-2623-4605-a036-9e9e63f22059

and has no problem installing.

sandy081 commented 6 years ago

@joaomoreno No clue why it says no permission for downloading one and not for other. Not sure what can be done here

octref commented 6 years ago

-rw-r--r--@

@cyrus86 Can you run xattr -l on that file?

https://apple.stackexchange.com/a/104875/225998 might be the cause.

MartinP7r commented 6 years ago

xattr -l is not returning anything on neither the tmp file of a successful installation nor the failed vetur installation

[T] xattr -l b16f60b8-7191-4cbc-8dad-31629cf57006                                                                       
[T] lsa b16f60b8-7191-4cbc-8dad-31629cf57006                                                                            
-rw-r--r--  1 USER  DOMAIN\Domain Users    23M Mar  8 10:01 b16f60b8-7191-4cbc-8dad-31629cf57006
[T] xattr -l 8356eeca-3848-48a1-90c2-c6d405b9352d                                                                       
[T] xattr -l 77abc78f-208c-40ea-af70-69137c6997b6
octref commented 6 years ago

Run it for the files where you see -rw-r--r--@ (notice the at sign at the end). I think you mentioned when you are running ls -ld $TMPDIR and lsa octref.vetur-0.11.7.vsix it's showing the at sign at the end, right?

https://unix.stackexchange.com/questions/106642/what-does-the-at-symbol-mean-on-osx-ls

MartinP7r commented 6 years ago

this only applies to the manually downloaded file. all other files in the temp folder have no extra attributes, only folders.
the manually downloaded vsix files output for xattr -l when downloaded into temp folder:

[T] xattr -l octref.vetur-0.11.7.vsix                                                                                                   14:45:01
com.apple.metadata:_kMDItemUserTags:
00000000  62 70 6C 69 73 74 30 30 A0 08 00 00 00 00 00 00  |bplist00........|
00000010  01 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00 00 09                    |..........|
0000002a
com.apple.metadata:kMDItemWhereFroms:
00000000  62 70 6C 69 73 74 30 30 A2 01 02 5F 10 6F 68 74  |bplist00..._.oht|
00000010  74 70 73 3A 2F 2F 6D 61 72 6B 65 74 70 6C 61 63  |tps://marketplac|
00000020  65 2E 76 69 73 75 61 6C 73 74 75 64 69 6F 2E 63  |e.visualstudio.c|
00000030  6F 6D 2F 5F 61 70 69 73 2F 70 75 62 6C 69 63 2F  |om/_apis/public/|
00000040  67 61 6C 6C 65 72 79 2F 70 75 62 6C 69 73 68 65  |gallery/publishe|
00000050  72 73 2F 6F 63 74 72 65 66 2F 76 73 65 78 74 65  |rs/octref/vsexte|
00000060  6E 73 69 6F 6E 73 2F 76 65 74 75 72 2F 30 2E 31  |nsions/vetur/0.1|
00000070  31 2E 37 2F 76 73 70 61 63 6B 61 67 65 50 08 0B  |1.7/vspackageP..|
00000080  7D 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00  |}...............|
00000090  03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000000A0  7E                                               |~|
000000a1
com.apple.quarantine: 0081;5aa8b7f8;Chrome;73337190-C366-4269-B72A-67BBAD733DC7

mostly the same, but just for completeness, when downloaded into normal system downloads folder:

[Downloads] xattr -l octref.vetur-0.11.7.vsix
com.apple.metadata:_kMDItemUserTags:
00000000  62 70 6C 69 73 74 30 30 A0 08 00 00 00 00 00 00  |bplist00........|
00000010  01 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00 00 09                    |..........|
0000002a
com.apple.metadata:kMDItemWhereFroms:
00000000  62 70 6C 69 73 74 30 30 A2 01 02 5F 10 6F 68 74  |bplist00..._.oht|
00000010  74 70 73 3A 2F 2F 6D 61 72 6B 65 74 70 6C 61 63  |tps://marketplac|
00000020  65 2E 76 69 73 75 61 6C 73 74 75 64 69 6F 2E 63  |e.visualstudio.c|
00000030  6F 6D 2F 5F 61 70 69 73 2F 70 75 62 6C 69 63 2F  |om/_apis/public/|
00000040  67 61 6C 6C 65 72 79 2F 70 75 62 6C 69 73 68 65  |gallery/publishe|
00000050  72 73 2F 6F 63 74 72 65 66 2F 76 73 65 78 74 65  |rs/octref/vsexte|
00000060  6E 73 69 6F 6E 73 2F 76 65 74 75 72 2F 30 2E 31  |nsions/vetur/0.1|
00000070  31 2E 37 2F 76 73 70 61 63 6B 61 67 65 50 08 0B  |1.7/vspackageP..|
00000080  7D 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00  |}...............|
00000090  03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000000A0  7E                                               |~|
000000a1
com.apple.quarantine: 0081;5aa8b688;Chrome;58BBAB47-EAF0-4994-B0B2-E23B48D9B569

sample of some folders that have an @ in the temp folder:

[T] xattr -l com.apple.soagent                                                                                                 
com.apple.quarantine: 0086;00000000;soagent;
[T] xattr -l 0c06db6a-e545-4426-946c-c372e9345fbd                                                                                       14:41:20
# actual tempfolder
[T] xattr -l .                                                                                                                  
com.apple.rootless: folders
[T] xattr -l com.renfei.SnippetsLabLaunchd                                                                                              
com.apple.quarantine: 0086;00000000;com.renfei.SnippetsLabLaunchd;                                                                                                         
[T] xattr -l "VSCode Crashes"                                                                                                         
org.chromium.crashpad.database.initialized: 1
joyfulelement commented 6 years ago

Also encountered the same issue with VS Code (Version 1.21.1) but with a different extension React Food Truck on macOS Sierra version 10.12.6.

The installation via extension VS Code GUI didn't work, then tried download .vsix and install it manually would gives you an error like below:

image

By examining the temporary file reported by this error also shows that there are missing executable bits: -rw-r--r-- 1 user 138145508 17977846 31 Mar 18:54 27c4fbc0-c377-4aa3-a901-06afd8ea81eb

Similarly, all other files created for this installation are also missing the executable bits: image

Couldn't find an workaround for it at the moment, because even if the missing executable bits are manually added after the failed installation attempt, by triggering the installation of the same extension will create the new temporary file with a different file name and re-raising the same error.

Also, there isn't seem to be a way to clean up all these temporary files that were created from the extension installation from VS Code. An option such as clean temporary installation file would be nice for reclaiming the unused disk space.

carrickjason commented 5 years ago

Not sure if this will help anyone but I was able to fix this by uninstalling TrendMicro. As soon as I did, I was able to install prettier-vscode just fine.

MartinP7r commented 5 years ago

Not sure if this will help anyone but I was able to fix this by uninstalling TrendMicro. As soon as I did, I was able to install prettier-vscode just fine.

Incidentally we also have TrendMicro installed on our machines at work (where this occurred).
I will try with and without TrendMicro and report back as soon as I can. Then at least the initial issue for this thread can be considered closed... 😅

MartinP7r commented 5 years ago

I was able to install Vetur without problems when there is no TrendMicro installed on the machine in question. So I suppose it's a 3rd party security software related issue and has nothing to do with VSCode. Maybe it messes with the temporary directory permissions.

For anybody ending up here with a similar problem: Please try to deactivate/uninstall your security software temporarily to confirm it's not an issue unrelated to vscode.

I'm closing this issue, since the initial problem is solved and not related to vscode.