Choco Installation fails. Complaining about elevated prompt even when launched in elevated prompt.
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
### What You Are Seeing?
Official installation steps (installation via `cmd.exe`) as described [here](https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe) fails to install choco on **some** of the Windows 10 machines.
### What is Expected?
Expected a smooth choco installation
### How Did You Get This To Happen? (Steps to Reproduce)
**Step 1:** Open cmd.exe (run as administrator)
**Step 2:** Run `@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"`.
**Step 3:** See the error and be sad :(
### Output Log
```
C:\Windows\system32>@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Extracting C:\Users\MyUser\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\MyUser\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
WARNING: Setting ChocolateyInstall Environment Variable on USER and not SYSTEM variables.
This is due to either non-administrator install OR the process you are running is not being run as an Administrator.
Creating ChocolateyInstall as an environment variable (targeting 'User')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Installation of Chocolatey to default folder requires Administrative permissions. Please run from elevated prompt.
Please see https://chocolatey.org/install for details and alternatives if needing to install as a non-administrator.
At C:\Users\MyUser\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:212 char:5
+ throw "Installation of Chocolatey to default folder requires Admi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Installation of...-administrator.:String) [], RuntimeException
+ FullyQualifiedErrorId : Installation of Chocolatey to default folder requires Administrative permissions. Please
run from elevated prompt. Please see https://chocolatey.org/install for details and alternatives if needing to in
stall as a non-administrator.
```
Contributor guide
Research direction
Start by reproducing the documented cmd.exe command and inspect the elevation-related logic in tools/chocolateysetup.psm1 around line 212, along with the install.ps1 flow shown in the command. Compare how administrator status is detected when PowerShell is launched from an elevated cmd.exe. Done means the documented installation completes on affected Windows 10 machines without reporting that the prompt is not elevated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100