chocolatey-archive / chocolatey

[DEPRECATED - https://github.com/chocolatey/choco] Chocolatey NuGet - Like apt-get, but for windows.
https://chocolatey.org
Apache License 2.0
2.81k stars 344 forks source link

32-bit 7za.exe with Install-ChocolateyZipPackage unzips to sysWOW64 #483

Closed JimFicarra closed 10 years ago

JimFicarra commented 10 years ago
32-bit 7za.exe: Filesystem redirection to syswow64

I created a package to deploy a zip of PowerShell modules to $PSHome\Modules (c:\windows\system32\WindowsPowerShell\v1.0\Modules). Since the 7za.exe that comes with Chocolatey is a 32-bit executable it is subject to file system redirection. The modules instead were installed to c:\windows\sysWOW64\WindowsPowerShell\v1.0\Modules, but the ChocolateyUninstall.ps1 I wrote to delete the files placed by the package failed becuase it tried to look system32.

I ended up writing a tweak in the Chocolatey install PS to ensure it gets to c:\Windows\sysnative\WindowsPowerShell\v1.0\Modules, but it would be a nice feature if perhaps both 32-bit and 64-bit 7zip exes are packaged with Chocolatey and the appropriate bitness was executed so it's transparent.

PowerShell I tried to replace sysWOW64 with sysnative to compensate but doesn't work.

$installDir = (Join-Path -Path $PSHOME -ChildPath Modules) -replace "sysWOW64", "sysnative"

Install-ChocolateyZipPackage "$packageName" "$url" "$installDir" "$url64"

JimFicarra commented 10 years ago

Ok - I had to force the $installDir with a hard-coded path to sysnative. My code above was being evaluated in a 64-bit powershell so it never got modified to sysnative. I use the below and I can get it to system32.

$installDir = "c:\Windows\sysnative\WindowsPowerShell\v1.0\Modules"

Still would be nice to have it use an appropriate bitness. :)

jberezanski commented 10 years ago

I've fixed this as part of GH-476. It is already merged, so it should be present in the next release.

As a side note, you're not supposed to put anything in System32\WindowsPowerShell\v1.0\Modules, that directory is reserved for modules that are part of Windows. Please see the Microsoft guidelines for installing PS modules.

JimFicarra commented 10 years ago

Awesome. Thank you as well for the advice and the link explaining the proper location of 3rd party modules. I'll switch my package to install to a more appropriate location and update the $PSModulePath environment variable.