chocolatey-archive/chocolatey

How can I get installed programs instantly in current cmd window?

ahmedmohiduet opened this issue · 12 comments

Every time I install a program I had to restarted my cmd window. Is there any convenient ways to get them in current cmd window? Simething like 'source file.sh' in unix ?

P.S. - I am using Windows 7

If you are in cmd.exe and not powershell you can type refreshenv

Chocolatey comes with a batch file named the above and will query the registry and reset all of your environment variables.

Perhaps we need more documentation surrounding that.

Is it possible to get RefreshEnv to work in powershell too?
If it cannot, there should be a warning message if RefreshEnv is used in powershell instead of a silent fail.

It's an issue with Windows inability to refresh shells. It doesn't have
anything to do with choco itself. Now that that is it off the way,
refreshenv is a stop gap for choco to keep you from having to close and
reopen your cmd window. Its also mostly undocumented. The recommendation is
that you close and reopen your shell.
You can also do PowerShell if you call &
c:\programdata\chocolatey\chocolateyinstall\helpers\Update-Session.ps1 (the
path may not be exactly right but you get the idea)- it may require
importing the module first and then calling update-session.

On Tuesday, January 27, 2015, Andy Li notifications@github.com wrote:

Is it possible to get RefreshEnv to work in powershell too?
If it cannot, there should be a warning message if RefreshEnv is used in
powershell instead of a silent fail.


Reply to this email directly or view it on GitHub
#666 (comment)
.

Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

Do you mean Update-SessionEnvironment? I tried adding it to the end of chocolateyInstall.ps1, but it seems to have no effect - the path var is not updated in powershell.

It actually does work but you need to call it separately outside of a choco
call (which starts up and closes a separate posh process).

On Tuesday, January 27, 2015, Andy Li notifications@github.com wrote:

Do you mean Update-SessionEnvironment
https://github.com/chocolatey/chocolatey/wiki/HelpersUpdateSessionEnvironment?
I tried adding it to the end of chocolateyInstall.ps1, but it seems to
have no effect - the path var is not updated in powershell.


Reply to this email directly or view it on GitHub
#666 (comment)
.

Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

Umm.. I thought the helpers are meant to be called inside chocolateyInstall.ps1...

Yes, they are. But anything they do with respect to environment vars only
lasts during that choco run. Once it comes back to the shell, all child
process changes are gone. It would be an egregious security issue with
Windows if child processes did more than they do to the parent process.

I'm giving you an option for updating your environment variables. Also
undocumented and not supported. Ymmv. Remember, you can just close and
reopen your shell as well.

On Tuesday, January 27, 2015, Andy Li notifications@github.com wrote:

Umm.. I thought the helpers are meant to be called inside
chocolateyInstall.ps1...


Reply to this email directly or view it on GitHub
#666 (comment)
.

Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

image

Hi Rob,

I was just able to reproduce it my win 7. First I run "choco install java". It says not found.Running "choco install jdk" also fails as you can see in the screen and after that new blank window appears it just freezes nothing happens after that.

@ahmedmohiduet does this fail if you switch over to 0.9.9?

I guess I will have to check it again. Will let you know after successful reproduce :)