Install-ChocolateyPath has bad logic #185

Open
Iristyle opened this Issue Oct 22, 2012 · 3 comments

Projects

None yet

2 participants

@Iristyle
Member

Oddly enough, the correct logic already appears in the file, but its commented

https://github.com/chocolatey/chocolatey/blob/master/src/helpers/functions/Install-ChocolateyPath.ps1#L10

  #$envPath = [Environment]::GetEnvironmentVariable('Path', $pathType)
  if (!$envPath.ToLower().Contains($pathToInstall.ToLower()))

If I ask to install a new PATH to SYSTEM, the local environment PATH (which is the combo of SYSTEM + USER + PROCESS) should not be considered.

If I need something to be accessible to the SYSTEM (for instance to a service process), then this check could prevent a good path from being registered for the SYSTEM.

I assume this is an attempt to prevent adding a PATH to multiple spots to save PATH space.. but it's assuming a little too much IMHO.

@Iristyle
Member

I think that script could use a bit of a refactor... there's a lot of unnecessary futzing around with ;

Just -split ';' into an array, add to the array if the -contains fails ... then -join ';'

@ferventcoder
Member

Agreed on refactoring - need to get in a PR that might fix this prior to a refactor though.

@ferventcoder
Member

Is this still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment