Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim install fails with error code 2 #500

Closed
dbrodsky opened this issue Jul 17, 2020 · 35 comments
Closed

Vim install fails with error code 2 #500

dbrodsky opened this issue Jul 17, 2020 · 35 comments
Assignees
Labels
Area-External Issue outside of winget-cli source Issue-Bug It either shouldn't be doing this or needs an investigation.
Milestone

Comments

@dbrodsky
Copy link

Brief description of your issue

When I try to install vim (technically gvim) using winget, the download succeeds but then it immediately errors out. Full output shown below:

PS C:\Users\(me)> winget install vim
Found vim [vim.vim]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Successfully verified installer hash
Installing ...
Installer failed with exit code: 2

Steps to reproduce

winget install vim

I also tried running with the -i flag, and when I do, instead of just erroring I get a popup dialog

2020-07-16

Light googling of the error message indicates it may be a problem with vim's installer. Nevertheless, silently failing is still an issue with winget.

Expected behavior

Vim installs

Actual behavior

Vim does not install

Environment

I am running as a nonprivileged user. I have not tried running PowerShell as administrator; I prefer to use this tool as a regular user and just do the admin account pw in a UAC dialog when necessary.

[winget --info]
Windows Package Manager v0.1.41821 Preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19041.388
Package: Microsoft.DesktopAppInstaller v1.0.41821.0

Thanks for reading! :)

@ghost ghost added the Needs-Triage Issue need to be triaged label Jul 17, 2020
@denelon
Copy link
Contributor

denelon commented Jul 17, 2020

@dbrodsky I was just able to install vim as a user. Can you check the logs?

@denelon denelon added Needs-Author-Feedback Issue needs attention from issue or PR author and removed Needs-Triage Issue need to be triaged labels Jul 17, 2020
@dbrodsky
Copy link
Author

@dbrodsky I was just able to install vim as a user. Can you check the logs?

Where do I find the log file? I tried passing --log to the winget install command but no log file appeared.

@ghost ghost added Needs-Attention Issue needs attention from Microsoft and removed Needs-Author-Feedback Issue needs attention from issue or PR author labels Jul 18, 2020
@megamorf
Copy link

This seems like a duplicate of #245

@denelon
Copy link
Contributor

denelon commented Jul 20, 2020

#390 would help here.

@dbrodsky
Copy link
Author

I think the Vim installer is not correctly attempting to get elevated permissions. That's the best I can come up with since I still don't know where winget makes its log files.

I tried running on a different PC, and it claims to install successfully but the installer never actually runs (it just flashes on the screen briefly).

PS C:\(Path)> winget install vim
Found vim [vim.vim]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/vim/vim-win32-installer/releases/download/v8.2.0916/gvim_8.2.0916_x64.exe
  ██████████████████████████████  9.12 MB / 9.12 MB
Successfully verified installer hash
Installing ...
Successfully installed!

So now, if I run in interactive mode with -i, it does indeed bring up the installer dialog as expected. However, when I get to the point where it will actually install, it fails because it does not have permission to write to C:\Program Files. Because the Vim installer never prompted me for elevated privileges.

PS C:\(Path)> winget install vim -i
Found vim [vim.vim]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/vim/vim-win32-installer/releases/download/v8.2.0916/gvim_8.2.0916_x64.exe
  ██████████████████████████████  9.12 MB / 9.12 MB
Successfully verified installer hash
Installing ...
Installer failed with exit code: 2

@megamorf It could be a duplicate of that ticket, certainly looks similar. However, there are other programs I can install successfully, such as PowerToys. Could be something with the Vim installer, or something janky in the handoff between winget and the installer where it can't elevate permissions.

@denelon denelon added Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Attention Issue needs attention from Microsoft labels Jul 24, 2020
@denelon denelon added this to the Package Manager Backlog milestone Jul 27, 2020
@denelon
Copy link
Contributor

denelon commented Jan 7, 2021

We've added the log location to winget --info. You can also use [Win]+[f] to submit feedback which attaches logs to submit bugs.

@dbrodsky
Copy link
Author

dbrodsky commented Jan 8, 2021

Thank you, @denelon -- here is my log file from running winget install vim

2021-1-7 08:23:46.819 [CORE] WinGet, version [0.2.3162], activity [{A4F7A180-79F0-4642-87C7-15F2BD4220C4}]
2021-1-7 08:23:46.820 [CORE] OS: Windows.Desktop v10.0.19042.685
2021-1-7 08:23:46.820 [CORE] Command line Args: "C:\Users\[user]\AppData\Local\Microsoft\WindowsApps\winget.exe" install vim
2021-1-7 08:23:46.820 [CORE] Package: Microsoft.DesktopAppInstaller v1.11.3162.0
2021-1-7 08:23:46.866 [CLI ] WinGet invoked with arguments: 'install' 'vim'
2021-1-7 08:23:46.867 [CLI ] Found subcommand: install
2021-1-7 08:23:46.867 [CLI ] Leaf command to execute: root:install
2021-1-7 08:23:46.867 [CORE] Setting action: Get, Type: UserFile, Name: settings.json
2021-1-7 08:23:46.912 [CORE] Settings loaded from settings.json
2021-1-7 08:23:46.912 [CORE] Setting .visual.progressBar not found. Using default
2021-1-7 08:23:46.912 [CORE] Setting .source.autoUpdateIntervalInMinutes not found. Using default
2021-1-7 08:23:46.912 [CORE] Setting .experimentalFeatures.experimentalCmd not found. Using default
2021-1-7 08:23:46.912 [CORE] Setting .experimentalFeatures.experimentalArg not found. Using default
2021-1-7 08:23:46.912 [CORE] Setting .experimentalFeatures.experimentalMSStore not found. Using default
2021-1-7 08:23:46.912 [CORE] Setting .experimentalFeatures.list not found. Using default
2021-1-7 08:23:46.912 [CORE] Setting .experimentalFeatures.upgrade not found. Using default
2021-1-7 08:23:46.912 [CLI ] Executing command: install
2021-1-7 08:23:46.912 [CORE] Setting action: Get, Type: Secure, Name: user_sources
2021-1-7 08:23:46.926 [CORE] Setting action: Get, Type: Standard, Name: sources_metadata
2021-1-7 08:23:46.927 [REPO] Default source requested, only 1 source available, using the only source: winget
2021-1-7 08:23:46.927 [CORE] Setting action: Get, Type: Secure, Name: user_sources
2021-1-7 08:23:46.927 [CORE] Setting action: Get, Type: Standard, Name: sources_metadata
2021-1-7 08:23:46.928 [REPO] Named source requested, found: winget
2021-1-7 08:23:46.928 [REPO] Source past auto update time [5 mins]; it has been at least 11387 mins
2021-1-7 08:23:47.007 [CORE] Examining extension: PFN = Microsoft.Winget.Source_8wekyb3d8bbwe, ID = IndexDB
2021-1-7 08:23:47.007 [CORE] Found matching extension.
2021-1-7 08:23:47.827 [CORE] Downloading to path: "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\Microsoft.Winget.Source_8wekyb3d8bbwe.msix"
2021-1-7 08:23:47.828 [CORE] Started applying motw to "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\Microsoft.Winget.Source_8wekyb3d8bbwe.msix" with zone: 3
2021-1-7 08:23:47.832 [CORE] Finished applying motw
2021-1-7 08:23:47.833 [CORE] Downloading from url: https://winget.azureedge.net/cache/source.msix
2021-1-7 08:23:48.106 [CORE] Download completed.
2021-1-7 08:23:48.108 [CORE] Starting AddPackage operation #0: file:///C:/Users/[user]/AppData/Local/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/TempState/WinGet/Microsoft.Winget.Source_8wekyb3d8bbwe.msixSkipSmartScreen: 1
2021-1-7 08:23:48.118 [CORE] Begin waiting for deployment #0
2021-1-7 08:23:48.118 [CORE] Begin blocking for deployment #0
2021-1-7 08:23:53.594 [CORE] Successfully deployed #0
2021-1-7 08:23:53.595 [CORE] Setting action: Set, Type: Standard, Name: sources_metadata
2021-1-7 08:23:53.623 [CORE] Examining extension: PFN = Microsoft.Winget.Source_8wekyb3d8bbwe, ID = IndexDB
2021-1-7 08:23:53.623 [CORE] Found matching extension.
2021-1-7 08:23:53.681 [REPO] Opening SQLite Index for ImmutableRead at 'C:\Program Files\WindowsApps\Microsoft.Winget.Source_2021.107.1325.984_neutral__8wekyb3d8bbwe\Public\index.db'
2021-1-7 08:23:53.681 [SQL ] Opening SQLite connection: 'file:/C:/Program Files/WindowsApps/Microsoft.Winget.Source_2021.107.1325.984_neutral__8wekyb3d8bbwe/Public/index.db?immutable=1' [1, 40]
2021-1-7 08:23:53.683 [REPO] Opened SQLite Index with version [1.1], last write [2021-1-7 07:25:00.000]
2021-1-7 08:23:53.684 [REPO] Performing search: Query:[none] Inclusions:PackageFamilyName='vim'[Exact] Inclusions:ProductCode='vim'[Exact] Inclusions:Id='vim'[CaseInsensitive] Inclusions:Name='vim'[CaseInsensitive] Inclusions:Moniker='vim'[CaseInsensitive]
2021-1-7 08:23:53.688 [CLI ] Found one app. App id: vim.vim App name: vim
2021-1-7 08:23:53.706 [REPO] Downloading manifest
2021-1-7 08:23:53.706 [CORE] Downloading from url: https://winget.azureedge.net/cache/manifests/vim/vim/9b28-8.2.1923.yaml
2021-1-7 08:23:53.999 [CORE] Download completed.
2021-1-7 08:23:54.000 [CLI ] Manifest fields: Name [vim], Version [8.2.1923]
2021-1-7 08:23:54.001 [CLI ] Starting installer selection.
2021-1-7 08:23:54.001 [CLI ] Completed installer selection.
2021-1-7 08:23:54.072 [CLI ] Generated temp download path: "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\vim.vim.8.2.1923"
2021-1-7 08:23:54.073 [CORE] Downloading to path: "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\vim.vim.8.2.1923"
2021-1-7 08:23:54.076 [CORE] Started applying motw to "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\vim.vim.8.2.1923" with zone: 3
2021-1-7 08:23:54.080 [CORE] Finished applying motw
2021-1-7 08:23:54.081 [CORE] Downloading from url: https://github.com/vim/vim-win32-installer/releases/download/v8.2.1923/gvim_8.2.1923_x64_signed.exe
2021-1-7 08:23:56.336 [CORE] Download hash: 9043d4d4522bafe612688d53ff881a0ac64ddd718c34f3c68ba01433341156e5
2021-1-7 08:23:56.336 [CORE] Download completed.
2021-1-7 08:23:56.337 [CLI ] Installer hash verified
2021-1-7 08:23:56.338 [CORE] Started applying motw to "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\vim.vim.8.2.1923" with zone: 2
2021-1-7 08:23:56.351 [CORE] Finished applying motw
2021-1-7 08:23:56.393 [CLI ] Installer args: /S
2021-1-7 08:23:56.395 [CLI ] Successfully renamed downloaded installer. Path: "C:\\Users\\[user]\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\TempState\\WinGet\\vim.vim.8.2.1923.exe"
2021-1-7 08:23:56.395 [CLI ] Starting installer: 'C:\Users\[user]\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\vim.vim.8.2.1923.exe' with arguments '/S'
2021-1-7 08:23:58.064 [CLI ] ShellExecute installer failed: 2
2021-1-7 08:23:58.065 [CLI ] Terminating context: 0x8a150006 at C:\BA\237\s\external\pkg\src\AppInstallerCLICore\Workflows\ShellExecuteInstallerHandler.cpp:c8

@kapsiR
Copy link

kapsiR commented Feb 3, 2021

I get this error when I try to install Stretchly too.

When I use the installer (in this case with the /S flag) manually, the installation succeeds.

winget --info:
Windows Package Manager v0.2.10191 Preview
Windows: Windows.Desktop v10.0.19042.746
Package: Microsoft.DesktopAppInstaller v1.11.10191.0

Logs:

2021-2-3 09:03:52.503 [CORE] Download completed.
2021-2-3 09:03:52.504 [CLI ] Installer hash verified
2021-2-3 09:03:52.504 [CORE] Started applying motw using IAttachmentExecute to C:\Users\usr\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\Stretchly.Stretchly.1.4.0
2021-2-3 09:03:52.523 [CORE] Finished applying motw using IAttachmentExecute. Result: 0 IAttachmentExecute::Save() result: 0
2021-2-3 09:03:52.544 [CLI ] Installer args: /S
2021-2-3 09:03:52.559 [CLI ] Successfully renamed downloaded installer. Path: C:\Users\usr\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\Stretchly.Stretchly.1.4.0.exe
2021-2-3 09:03:52.560 [CLI ] Starting: 'C:\Users\usr\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\Stretchly.Stretchly.1.4.0.exe' with arguments '/S'
2021-2-3 09:03:58.914 [CLI ] ShellExecute installer failed: 2
2021-2-3 09:03:58.915 [CLI ] Terminating context: 0x8a150006 at C:\BA\246\s\external\pkg\src\AppInstallerCLICore\Workflows\ShellExecuteInstallerHandler.cpp:dc

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

Screenshot 2021-03-31 221056

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

Screenshot 2021-03-31 221308

@kapsiR
Copy link

kapsiR commented Apr 1, 2021

grafik

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

@kapsiR can you share winget --info?

@kapsiR
Copy link

kapsiR commented Apr 1, 2021

Sure:

winget --info
Windows Package Manager v0.2.10771 Preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19042.867
Package: Microsoft.DesktopAppInstaller v1.11.10771.0

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

@kapsiR can you upgrade your client? I'm trying to figure out if it's a client issue, an OS issue, or something with the installer. I did a clean install, and I've seen a couple of apps that throw errors when you try a subsequent install.

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

@kapsiR nevermind, I see you are on the latest release :(

@kapsiR
Copy link

kapsiR commented Apr 1, 2021

I'm using the App Installer from the Store, can there be any difference with a directly installed appxbundle?

@denelon
Copy link
Contributor

denelon commented Apr 1, 2021

The one key difference is the version of APP Installer in the Microsoft Store is automatically updated when we publish new releases there.

This issue looks like it's related to the installers. You may need to reach out to the publishers to determine what exit code 2 means.

Please thumbs up this issue: hovancik/stretchly#893

@denelon
Copy link
Contributor

denelon commented Apr 6, 2021

I'm not sure about the integrity level comment in the stretchly issue, but I'm noting it here so we can look to see if that may have something to do with the issue.

@denelon
Copy link
Contributor

denelon commented Apr 6, 2021

@kapsiR you can test the x64 using a local copy of the manifest and using winget install -m <path to manifest>. If that works, it's a small PR :)

@ghost
Copy link

ghost commented May 8, 2021

@denelon

it seems winget checks for installers UAC permissions , hence denying UAC results in winget reporting installation canceled.
Screenshot 2021-05-08 035405

trying to manually downloading and installing also fails because installer doesn't auto elevate from standard account. installing to ~\UserFolder installs fine but doesn't register to ARP list :) (irony)
Screenshot 2021-05-08 040531
but the same installer auto elevates when run from admin account.
those who had commented that choco installs fine, most probably they had run those installers from an admin account.

It seems NSIS Installers check for admin accounts and only elevate the installers when run from admin accounts only.
don't know if this is a unfixed bug or what. but this is how it is.
found a similar looking github issue here : electron-builder: NSIS fails for standard users?
NSIS Installer references site says :

Windows Vista/7 automatically identifies NSIS installers and decides administrator privileges are required.

My suggestion : since it seems this is not vim or stretchly specific issue rather a generic issue of NSIS installers, I will suggest you to close this issue and focus on implementing following behaviors :
when implementing User vs System ,

  1. a system/all users switch should auto elevate installers/uninstallers, thus issues like these could be solved.
  2. a particular user/self switch should also register the program to user ARP list. so that winget list can list them.

just my 2 cents :)

@denelon
Copy link
Contributor

denelon commented May 8, 2021

@ecovio1 thank you for such thorough analysis. This will certainly help guide a better solution.

@denelon denelon added the Area-External Issue outside of winget-cli source label May 8, 2021
@denelon
Copy link
Contributor

denelon commented May 8, 2021

I've marked this Area-External to indicate it's a challenge with NSIS installers. We've got another Issue or two to create for User vs. Machine installation, so I'll keep this open until that is implemented. I'll link the Issue when we have it better defined.

@kapsiR
Copy link

kapsiR commented May 28, 2021

I'd like to add here the current state with the following winget --info:

Windows Package Manager v1.0.11451
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19042.985
Package: Microsoft.DesktopAppInstaller v1.11.11451.0

Stretchly v1.7.0 now installs successfully when winget install has been started from an elevated prompt. 🎉
Otherwise, it seems there is an error with the setup (no UAC prompt / no elevation) while it tries to write to C:\Windows\TEMP\.

Verified it with Process Monitor:
grafik

@Jaifroid
Copy link

Jaifroid commented Jun 5, 2021

I'm having the same problem testing an NSIS (Nullsoft) install package made with Electron-Builder which I'ld like to release via winget. The installer works fine when run from PowerShell with the /S switch, and installs silently defaulting to CurrentUser (as expected). However, if I attempt to install the same package using a wincreate manifest, the installer exits with Code 2 (and doesn't install anything). I read somewhere (sorry don't have the reference) that NSIS Code 2 means "invalid commandline switches". I have checked the logs and the correct commandline appears to be being used:

2021-06-05 15:37:45.915 [CLI ] Installer args: /S
2021-06-05 15:37:45.973 [CLI ] Successfully renamed downloaded installer. Path: C:\Users\xxxx\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\Kiwix.KiwixJS.Electron.1.3.0-E.exe
2021-06-05 15:37:45.974 [CLI ] Starting: 'C:\Users\xxxx\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\Kiwix.KiwixJS.Electron.1.3.0-E.exe' with arguments '/S'
2021-06-05 15:37:51.785 [CLI ] ShellExecute installer failed: 2
2021-06-05 15:37:51.786 [CLI ] Terminating context: 0x8a150006 at C:\BA\311\s\external\pkg\src\AppInstallerCLICore\Workflows\ShellExecuteInstallerHandler.cpp:d7

I don't know if it's relevant that this is a 32bit binary, with the aim of targetting both x86 and x64 with the one package (being Electron, this makes absolutely no difference for the end user and simplifies things a lot for the Dev!). There are some strange "FAIL" log entries relating to that (I think), don't know if they're relevant:

2021-06-05 15:37:45.069 [REPO] Examining ARP entries for Machine | X64
2021-06-05 15:37:45.206 [REPO] Examining ARP entries for Machine | X86
2021-06-05 15:37:45.211 [FAIL] C:\BA\311\s\external\pkg\src\AppInstallerRepositoryCore\Microsoft\Schema\1_0\Interface_1_0.cpp(184)\AppInstallerCLI.exe!00007FF70B7FDC33: (caller: 00007FF70B7F9E43) Exception(1) tid(5238) 800700B7 Cannot create a file when that file already exists.
2021-06-05 15:37:45.211 [REPO] Ignoring duplicate ARP entry Machine|X86|7-Zip [7-Zip 16.04]
2021-06-05 15:37:45.478 [REPO] Examining ARP entries for User | X64

I've tried changing the InstallerType entry from nullsoft to exe and manually adding the /S switch to the manifest, but same error occurs. Could it be that the commandline switches are not being passed correctly to PowerShell? Are they being accidentally passed as a string?

This is what the Installer manifest looks like (the exe version) -- the nullsoft version is same with InstallerType set to nullsoft and the InstallerSwitches removed:

PackageIdentifier: Kiwix.KiwixJS.Electron
PackageVersion: 1.3.0-E
InstallModes:
  - interactive
  - silent
  - silentWithProgress
Installers:
- Architecture: x86
  InstallerType: exe
  InstallerUrl: https://github.com/kiwix/kiwix-js-windows/releases/download/v1.3.0E/Kiwix.JS.PWA.Setup.1.3.0-E.exe
  InstallerSha256: E091416165E02802D44D7EB6D27D24260BC4C0645FB28471A9575CA922C65504
  InstallerSwitches:
    Silent: /S
ManifestType: installer
ManifestVersion: 1.0.0

@Jaifroid
Copy link

Jaifroid commented Jun 5, 2021

I have some further information that can help diagnose this, I think. I tried running the manifest in my previous message with the -i (interactive) switch, and this time it revealed the error:

image

This suggests a very different error from what I was suspecting, and suggests some underlying problem with paths in the handover between winget and NSIS installers...

@denelon denelon added this to WinGet Sep 29, 2021
@denelon denelon modified the milestones: Backlog-Client, v1.2-Client Oct 1, 2021
@denelon
Copy link
Contributor

denelon commented Dec 1, 2021

This will be fixed by:

@denelon
Copy link
Contributor

denelon commented Jun 21, 2022

vim

@denelon denelon closed this as completed Jun 21, 2022
Repository owner moved this from Assigned to Done in WinGet Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-External Issue outside of winget-cli source Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
Archived in project
Development

No branches or pull requests

7 participants