Winget-cli: Permission Denied when running from bash

Created on 20 May 2020  Â·  8Comments  Â·  Source: microsoft/winget-cli

Brief description of your issue

Whenever you run an winget install from bash from git for windows, it always gives a message such as the following. Note: Tried this in Windows Terminal and Git for Windows bash terminal (Mingw64) and it had the same effect. Both times running as admin.

$ winget install powertoys
bash: /c/Users/.../AppData/Local/Microsoft/WindowsApps/winget: Permission denied

Interestingly enough, running it from cmd seems to work.

Steps to reproduce

  1. Install winget.
  2. Open up a bash terminal in Windows Terminal as admin
  3. Run winget install powertoys

Note: Running any other command such as winget --version also gives a permission denied error.

Expected behavior


Installs powertoys package

Actual behavior

Permission denied

Environment

Even running winget --version gives a permission denied error.

[winget --info]
Windows Package Manager v0.1.41331 Preview
Windows: Windows.Desktop v10.0.18362.836
Package: Microsoft.DesktopAppInstaller v1.0.41331.0
Issue-Bug

Most helpful comment

@KevinLaMS this is a different issue:

  1. Install Git
  2. Install from https://github.com/microsoft/winget-cli/releases
  3. Open Git Bash
  4. Run winget
~/Desktop: winget

bash: /c/Users/<username>/AppData/Local/Microsoft/WindowsApps/winget: Permission denied


winget cannot be started from a Git Bash prompt.

All 8 comments

Duplicate of #189 Looks to be a duplicate reactivate if you disagree.

@KevinLaMS this is a different issue:

  1. Install Git
  2. Install from https://github.com/microsoft/winget-cli/releases
  3. Open Git Bash
  4. Run winget
~/Desktop: winget

bash: /c/Users/<username>/AppData/Local/Microsoft/WindowsApps/winget: Permission denied


winget cannot be started from a Git Bash prompt.

Yeah, even running winget --version gives a Permission denied

I looked into /c/Users/.../AppData/Local/Microsoft/WindowsApps/ and it's full of 0 byte executables. There is some dark magic for store apps involved here which Bash doesn't understand. (Actually no program seems to be able to open these files - e.g. Notepad++)

Maybe @KevinLaMS can give a hint what is going on there, and we can open a bug on the Git/Bash side...

EDIT: found this https://www.google.com/search?q=windows+10+app+execution+aliases

@Hades32 I keep thinking I've already sent in the bug (this has been affecting Python for over a year now), but then can never find it again, so feel free to send it in again.

The issue is that Cygwin's spawn() implementation tries to read the file (looking for the PE header?) and fails, and so returns that Permission Denied error. These are not real files on disk, unfortunately, but reparse points, so all you can do with them is execute (CreateProcess). Probably the best fix is for Cygwin to skip the PE header check if the extension is .exe, but checking for IO_REPARSE_TAG_APPEXECLINK in the reparse tag and then going ahead with launching it would also work.

Edit: Of course, once Cygwin has the fix it'll have to flow down. It may make more sense to fix it further downstream first, but I was told that the original code is part of Cygwin and just inherited by MinGW and Git Bash.

Created an issue in git-for-windows: Permission Error on all App Execution Aliases in git-bash #2675 with some more diagnostic info.

It's definitely related to App Execution Aliases, so might be out of scope for winget-cli as it's currently deployed, but might put on the roadmap offering a non-windows store deployment option so it can be used in bash unless the issue can be fixed.

I have figured out a workaround that worked for me in WSL2 in regards of running winget from bash.

https://github.com/microsoft/winget-cli/issues/234#issuecomment-647641718

Pude resolver el problema, gracias! Fierro pariente! OKno, thanks for the instructions to solve the Permision denied problem I had.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TomBrien picture TomBrien  Â·  4Comments

AdilHindistan picture AdilHindistan  Â·  3Comments

sayedarifuddin picture sayedarifuddin  Â·  3Comments

denelon picture denelon  Â·  4Comments

auchenberg picture auchenberg  Â·  3Comments