Choco: Chocolatey trying to install in non-elevated environment

Created on 9 Apr 2015  路  11Comments  路  Source: chocolatey/choco

There seems to be bug with installing while the user have not enough privileges.

  1. Install fresh Windows.
  2. Open the _non-elevated_ cmd.exe.
  3. Execute an install instruction from the Chocolatey site: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
  4. It asks whether the user wants to install it:

```
Installing chocolatey on this machine
Chocolatey v0.9.9.4

Chocolatey detected you are not running from an elevated command shell
(cmd/powershell). You may experience errors - many functions/packages
require admin rights. Only advanced users should run choco w/out an
elevated shell. When you open the command shell, you should ensure
that you do so with "Run as Administrator" selected.

Do you want to continue?
1) yes
2) no [Default - Press Enter]
```

  1. I've pressed Enter and it still trying to do something! (And, yep, it failed.)

```
Import-Module : The specified module 'C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateyInst
all\helpers\chocolateyInstaller.psm1' was not loaded because no valid module file was found in any module directory.
At C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:50 char:3

  • Import-Module $installModule -Force
  • ~~~~~~~
  • CategoryInfo : ResourceUnavailable: (C:\Users\Friedr...yInstaller.psm1:String) [Import-Module], FileNot
    FoundException
  • FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Install-ChocolateyEnvironmentVariable : The term 'Install-ChocolateyEnvironmentVariable' is not recognized as the name
of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:138 char:3

  • Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVa ...
  • ~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (Install-ChocolateyEnvironmentVariable:String) [], CommandNotFoundExcept
    ion
  • FullyQualifiedErrorId : CommandNotFoundException

Test-ProcessAdminRights : The term 'Test-ProcessAdminRights' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:139 char:7

  • if (Test-ProcessAdminRights) {
  • ~~~~~~~
  • CategoryInfo : ObjectNotFound: (Test-ProcessAdminRights:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException
    ```

    1. And it asked me again if I want to do anything, and I said "no" again, and it did something again:

```
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
Chocolatey v0.9.9.4

Chocolatey detected you are not running from an elevated command shell
(cmd/powershell). You may experience errors - many functions/packages
require admin rights. Only advanced users should run choco w/out an
elevated shell. When you open the command shell, you should ensure
that you do so with "Run as Administrator" selected.

Do you want to continue?
1) yes
2) no [Default - Press Enter]

Ensuring 'C:\ProgramData\chocolatey\lib\chocolatey' exists.
WARNING: C:\ProgramData\chocolatey\redirects does not exist
Test-ProcessAdminRights : The term 'Test-ProcessAdminRights' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:409 char:7

  • if (Test-ProcessAdminRights) {
  • ~~~~~~~
  • CategoryInfo : ObjectNotFound: (Test-ProcessAdminRights:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Install-ChocolateyPath : The term 'Install-ChocolateyPath' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:416 char:3

  • Install-ChocolateyPath -pathToInstall "$chocolateyExePath" -pathTyp ...
  • ~~~~~~
  • CategoryInfo : ObjectNotFound: (Install-ChocolateyPath:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Import-Module : The specified module 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1' was not loaded
because no valid module file was found in any module directory.
At C:\Users\Friedrich\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:110 char:3

  • Import-Module "$realModule" -Force
  • ~~~~~~~~~~
  • CategoryInfo : ResourceUnavailable: (C:\ProgramData...yInstaller.psm1:String) [Import-Module], FileNot
    FoundException
  • FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
```

Invalid / Not Issue / No repro / Not Implementing

Most helpful comment

  • Type cmd on windows search

  • Right click on CMD result, and click run as administrator.

...you're using elevated prompt, and the command should run now.

All 11 comments

I don't see this as an issue as the website states you need to use an elevated command prompt to install.

The PowerShell Installer (chocolateyInstall.ps1) is calling choco.exe several times during the install, each of those times the question pops up. Each time you select no, that individual run of choco.exe stops, but then the next one runs. The errors about unable to find things are because the calls to choco are to unpack the other files, when you tell it no, it doesn't unpack.

image

When you click that link, see the following: https://github.com/chocolatey/choco/wiki/Installation#non-administrative-install

The answer here for non-admin is the link above, which explains not to install to the default location.

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\MINTU\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1:211 char:5

  • throw "Installation of Chocolatey to default folder requires Admi ...
  • Type cmd on windows search

  • Right click on CMD result, and click run as administrator.

...you're using elevated prompt, and the command should run now.

My solution was to run as administrator powershell

* Type cmd on windows search

* Right click on CMD result, and click run as administrator.

...you're using elevated prompt, and the command should run now.

So i did try this, but i'm getting this "WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'."

@Sriramkothandaraman that is normal messages for the install. Those are warnings so you take note of the information being provided, but unless it goes red, it's not an error. :D

* Type cmd on windows search

* Right click on CMD result, and click run as administrator.

...you're using elevated prompt, and the command should run now.

So i did try this, but i'm getting this "WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'."

Thank you it works

Was this page helpful?
0 / 5 - 0 ratings