Open bharathmuppa opened 5 days ago
The logs say:
Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
Which indicates it's not finding the environment variable you created.
You didn't mention how you created the ChocolateyInstall
environment variable and targetting which scope.
The documentation states:
Create a machine level (user level will also work) environment variable named ChocolateyInstall and set it to the folder you want Chocolatey to install to prior to installation (this environment variable must be set globally or available to PowerShell- it is not enough to simply make it available to your current command prompt session).
The logs say:
Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
Which indicates it's not finding the environment variable you created.
You didn't mention how you created the
ChocolateyInstall
environment variable and targetting which scope.The documentation states:
Create a machine level (user level will also work) environment variable named ChocolateyInstall and set it to the folder you want Chocolatey to install to prior to installation (this environment variable must be set globally or available to PowerShell- it is not enough to simply make it available to your current command prompt session).
When I started, I created a single script where I changed the environment variables and then ran install.ps1 as you can see in the script. However, after digging deeper, I realized that the environment variable changes were updated in a process other than install.ps1. Therefore, I moved that logic to another file and ran it before executing install.ps1. I ran this new script first and then, after its successful execution, I ran install.ps1.
In point 2, I posted the log of me printing the path in the other PowerShell script before install.ps1 starts executing.
@bharathmuppa, I've done some digging on this, and I think I can explain what's happening. It looks like you're setting the ChocolateyInstall
environment variable at the machine level, which is what the docs suggest. However, it would seem then that you're not loading a new PowerShell process from Windows Explorer, so the environment variable is not being made available to the Chocolatey install script.
What I have done that I can confirm works:
$env:ChocolateyInstall = 'C:\ProgramData\choco'
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
In your script, if you update your environment variable check to use this: [System.Environment]::GetEnvironmentVariable('ChocolateyInstall', [System.EnvironmentVariableTarget]::Process)
I suspect that you will not see it set in the process level which is where Chocolatey needs it to be set.
I've opened an issue on the docs repository here: https://github.com/chocolatey/docs/issues/1031 to get the docs updated to be more clear.
Checklist
What You Are Seeing?
Not able to install choco in AppData or in any other custom location.
What is Expected?
If i set environment variable CholateyInstall prior to the installation, Choco should be installed in specified location as official Docs
How Did You Get This To Happen?
powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass "C:\Users\****\automation\install-choco-env.ps1"
System Details
Installed Packages
Output Log
Additional Context
No response