Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix Chocolatey "Access is Denied"

Tags:

chocolatey

I just installed Chocolatey for the first time using this command in an admin cmd:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Admin cmd output:

Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.13.
Extracting C:\Users\CurrentUser\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\CurrentUser\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  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.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

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\CurrentUser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
WARNING: Unable to run Chocolately at this time.  It is likely that .Net Framework installation requires a system reboot
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
Ensuring chocolatey.nupkg is in the lib folder

After restarting my cmd I still can't access choco commands:

enter image description here

There does not seem to be documentation on why this happens. How can this be fixed?

like image 637
Jmaurier Avatar asked Apr 09 '19 19:04

Jmaurier


People also ask

How do I use Chocolatey on Windows 10?

Install via Command LinePress the Windows key and type "cmd". Select the Run as administrator option. Wait for the installation process to finish to start using Chocolatey. Note: Make sure to close and reopen the shell before using Chocolatey to ensure all the environment variables are loaded correctly.

Where do I install Chocolatey?

NOTICE: As of 0.9. 8.24, Chocolatey's default install location is C:\ProgramData\Chocolatey.

How does Chocolatey install work?

Chocolatey is a tool that automates all the mundane getting and installing software work for you. You just select what you want installed and within a few minutes, Chocolatey has downloaded and installed (or upgraded) that software without need for further input from you.


2 Answers

run your command prompt as administration then run command "choco install nodejs"

like image 88
pavan kumar Avatar answered Sep 29 '22 14:09

pavan kumar


This is related probably to antivirus, in my case was Sophos and needed to add choco as a whitelist

like image 26
Jose De Gouveia Avatar answered Sep 29 '22 14:09

Jose De Gouveia