-
Notifications
You must be signed in to change notification settings - Fork 342
Allowing ChocolateyInstall from System & Proc Env #135
Conversation
if ($userVar -ne $folder) { | ||
write-host "Creating $chocInstallVariableName as a User Environment variable and setting it to `'$folder`'" | ||
[Environment]::SetEnvironmentVariable($chocInstallVariableName, $folder, [System.EnvironmentVariableTarget]::User) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when you are a regular user who has never installed before, how do you get the environment variable set? Am I misunderstanding that process environment variable will aways be set?
Fixing logic around setting the chocolatey path. This allows a user to preset a system or user environment variable or specify a process based environment variable. We only set a user variable if the install directory came from a process based env or if it was the default. Usage for Proc Based which will set a permanent user env var: SET ChocolateyInstall=C:\Opt && @PowerShell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))" && SET PATH=%PATH%;%ChocolateyInstall%\bin
That was a good catch. In my testing I realize I always had a var set in which case the default value was always falling through. The idea I am thinking of is that I only want to set the variable if its the Default or if the User overrides it via the "Process" scope environment variable. Otherwise the variable came from System or User scope in which case an explicit User scoped environment variable doesn't need to be written because something already exists. Does that make sense? I updated the pull request to fix the issue, let me know if there is anything else you would like me to do. |
i'd want to use exclusively system variables. so what do i need to do exactly? is there a problem with passing params to InstallChocolatey.ps1 that this can't be done within it? isn't that what's in the bit.ly url that gets invoked? |
I am all for passing parameters, is that possible, seems like a big change?
|
system vars require admin - that's why the default goes to user. To go to system, it would just take adding them manually and applying this fix for now. I think in the future we could make the installer smarter. |
I was shooting for an optional switch if specified, while running under admin that could do it for me :) I have been installing chocolatey on 400 servers and I have seen some bizzare issues with environment path modification and powershell putting in 2 semi-colons or none. |
Weird. Interesting. It might be a bug somewhere in chocolatey's installer script. |
I actually just run my own bootstrap first that configures The installer could use some work. The biggest issue is the lack of named Maybe a dictionary hash or reference to a simple property file as the only
|
I would be fine with more named parameters in there. Keep in mind that whatever is done, it should work without the supplied parameters or property files. |
I saw a discussion here - http://stackoverflow.com/questions/4225748/how-do-i-pass-named-parameters-with-invoke-command which uses script blocks- somewhat convoluted. |
Agree. Can we do a git fetch upstream and git rebase upstream/master (assuming your chocolatey/chocolatey remote is upstream). Lets get the innovation, but lets get @abombss to a git rebase -i fixup on the 2nd commit, especially since it mods the same file, and we want every commit to stand on its own as workable going forward. |
Think I'm getting ready to pull this in. We'll also be rewriting this to make it a ton cleaner as well. |
This being the installer, not your code. :) |
Definitely want to get this into .21 |
Based on the discussion in the google group
https://groups.google.com/forum/?fromgroups#!topic/chocolatey/84nMqjleMcI
This patch adds support for System and Proc based environment variable when installing chocolatey.
This still sets the path only for the user, but I am assuming if using system or proc the person installing will manually override the path.