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

Environment Variable Changes May Require Reboot #728

Closed
flcdrg opened this issue May 8, 2016 · 15 comments
Closed

Environment Variable Changes May Require Reboot #728

flcdrg opened this issue May 8, 2016 · 15 comments

Comments

@flcdrg
Copy link
Member

flcdrg commented May 8, 2016

What You Are Seeing?

C:\dev\git\chocolatey-beyondcompare-integration [master +0 ~2 -0 !]> choco pack
Error when registering components for 'chocolatey.licensed.infrastructure.app.registration.ContainerBinding':
 Exception has been thrown by the target of an invocation.
Error when setting configuration for 'chocolatey.licensed.infrastructure.app.builders.ConfigurationBuilder':
 Exception has been thrown by the target of an invocation.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\config\chocolatey.config' is denied.
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\config\chocolatey.config' is denied.
Maximum tries of 3 reached. Throwing error.
Error serializing type chocolatey.infrastructure.app.configuration.ConfigFileSettings:
 Access to the path 'C:\ProgramData\chocolatey\config\chocolatey.config' is denied.
Error updating 'C:\ProgramData\chocolatey\config\chocolatey.config'. Please ensure you have permissions to do so:
 Access to the path 'C:\ProgramData\chocolatey\config\chocolatey.config' is denied.
Chocolatey v0.9.10-beta1-322-g791d56e Professional
Attempting to build package from 'beyondcompare-integration.nuspec'.
Successfully created package 'beyondcompare-integration.1.0.0.nupkg'

What is Expected?

How Did You Get This To Happen? (Steps to Reproduce)

Running choco pack from non-elevated shell.

I don't remember seeing these errors with the previous chocolatey.extension (assuming that is involved)

@ferventcoder
Copy link
Member

Upgrade to the latest prerelease and let me know if you are still seeing this issue. This is fallout from #724.

@ferventcoder
Copy link
Member

What happens is that the install tries to remove the user environment variable for "ChocolateyInstall" but due to the bug in #724 it was actually creating an empty one.

The extension starts failing because it can't find the path to itself anymore. Possibly we need a secondary way for it to validate its location.

@ferventcoder
Copy link
Member

If that is not what you are seeing (the empty environment variable in user), then it's the other fallout from #303 - which is that we need a way to trigger the system to see that the environment variables have updated and it should respond accordingly.

refreshenv is a way to trigger that locally, but if you close and reopen your shell and it comes back (and you don't have the empty environment variable), then a reboot will resolve it until we add more fixes to trigger the update.

@ferventcoder
Copy link
Member

Let me know which of the above apply. Thanks!

@flcdrg
Copy link
Member Author

flcdrg commented May 8, 2016

I thought I'd checked and was running the latest preview. I'll double check just to be sure.

Sent from my Windows Phone


From: Rob Reynoldsmailto:notifications@github.com
Sent: ‎8/‎05/‎2016 10:53 PM
To: chocolatey/chocomailto:choco@noreply.github.com
Cc: David Gardinermailto:david@gardiner.net.au; Authormailto:author@noreply.github.com
Subject: Re: [chocolatey/choco] Errors running choco pack from non-elevated prompt (#728)

Let me know which of the above apply. Thanks!


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#728 (comment)

@flcdrg
Copy link
Member Author

flcdrg commented May 9, 2016

I'm using 0.9.10-beta-20160506 with v1.3.0 of chocolatey.extension.

I have a 'ChocolateyInstall' environment variable set as a system variable, but nothing as a user variable.

@ferventcoder
Copy link
Member

And when you open a new shell and type $env:ChocolateyInstall (posh) or %ChocolateyInstall% (cmd.exe), what do you get?

If it is empty, call refreshenv. Then see if the value is set. If it is not empty and it was before, you will need a reboot or run setx trigger 1 to jumpstart explorer.exe.

@ferventcoder
Copy link
Member

Of course this assumes you are seeing the issues still.

@flcdrg
Copy link
Member Author

flcdrg commented May 9, 2016

Yes, still seeing that error.

$env:ChocolateyInstall gives C:\ProgramData\chocolatey

@ferventcoder ferventcoder changed the title Errors running choco pack from non-elevated prompt Environment Variable Changes Require Reboot May 9, 2016
@ferventcoder ferventcoder added this to the 0.9.10 milestone May 9, 2016
@ferventcoder ferventcoder self-assigned this May 9, 2016
@ferventcoder
Copy link
Member

That is strange that you are still seeing this error. Does it persist after reboot?

@ferventcoder
Copy link
Member

I should have what I believe is a fix for this soon.

@ferventcoder ferventcoder changed the title Environment Variable Changes Require Reboot Environment Variable Changes May Require Reboot May 9, 2016
ferventcoder added a commit that referenced this issue May 9, 2016
Setting environment variables directly in the registry has a side
effect of sometimes not letting explorer.exe know that something
changed. When that happens, it doesn't matter if you open a new shell
or not, the environment variables available to new shells will reflect
the older values.

The fix for this is a two fold attack - broadcast the change and set
another environment variable with SetX.

Broadcasting the change using the native method
`SendMessageTimeout` has no effect on currently open shells, but helps
GUIs and explorer.exe realize that something changed and that they
should look to refresh their environment values.

SetX.exe also has no effect on the current shell, but it forces
explorer.exe to refresh the values that are available. Set a user
environment variable with the current date and time.  This also has a
nice side effect of letting the user know the last time the environment
was updated by Chocolatey.

If either of these fail, report the error as a warning.
ferventcoder added a commit that referenced this issue May 9, 2016
* stable:
  (doc) update CHANGELOG/nuspec
  (GH-728) Fix: Env var changes may require reboot
  (GH-729) Update env after setting env vars for scripts
  (GH-723) Warn when can't find file
  (GH-723) Convert msiexec to full path
  (GH-723) Ensure wusa.exe uses a full path
  (GH-727) Fix: Name is bad if response has params
@ferventcoder
Copy link
Member

This has been released in https://chocolatey.org/packages/chocolatey/0.9.10-beta-20160509

You can upgrade to it with choco upgrade chocolatey --version 0.9.10-beta-20160509 or after another hour or so you can use choco upgrade chocolatey -pre.

TheBigBear pushed a commit to TheBigBear/choco that referenced this issue May 14, 2016
Setting environment variables directly in the registry has a side
effect of sometimes not letting explorer.exe know that something
changed. When that happens, it doesn't matter if you open a new shell
or not, the environment variables available to new shells will reflect
the older values.

The fix for this is a two fold attack - broadcast the change and set
another environment variable with SetX.

Broadcasting the change using the native method
`SendMessageTimeout` has no effect on currently open shells, but helps
GUIs and explorer.exe realize that something changed and that they
should look to refresh their environment values.

SetX.exe also has no effect on the current shell, but it forces
explorer.exe to refresh the values that are available. Set a user
environment variable with the current date and time.  This also has a
nice side effect of letting the user know the last time the environment
was updated by Chocolatey.

If either of these fail, report the error as a warning.
@warpdesign
Copy link

warpdesign commented Nov 5, 2016

I am getting the same error, just installed chocolatey using an elevated prompt (as suggested) and I get the same error as @flcdrg when running choco from a non-elevated prompt.

I'm using Chocolatey 0.10.3 on Windows 10.

@warpdesign
Copy link

After a reboot it works, but the installation scripts advices to restart any prompt, not to restart the computer: maybe it could be more precise ?

@ferventcoder
Copy link
Member

@warpdesign I'm not sure what you are running into is quite the same. This issue was about trying to use Chocolatey licensed edition with Chocolatey immediately after install. Perhaps you can expand on what you are running into as part of a new issue? Thanks!

@gep13 gep13 removed the 4 - Done label Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants