How to uninstall a package when it has been installed in a custom directory?
030 opened this issue · 11 comments
It seems that it is not possible to overwrite variables, while the variable exist in the chocolateyInstall.ps1:
c:\HashiCorp>choco install eclipse -Version 4.4.1 -extractionPath c:\temp
Chocolatey (v0.9.8.28) is installing 'eclipse' and dependencies. By installing you accept the license for 'eclipse' and each
dependency you are installing.
eclipse v4.4.1
Extracting C:\Users\r\AppData\Local\Temp\chocolatey\eclipse\eclipseInstall.zip to c:\Program Files\Eclipse Foundation\4.4.1..
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 11/30/2014 22:31 4.4.1
c:\Program Files\Eclipse Foundation\4.4.1
eclipse has finished successfully! The chocolatey gods have answered your request!
Finished installing 'eclipse' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.
Chocolatey (v0.9.8.28) is installing '-extractionPath' and dependencies. By installing you accept the license for '-extractionPath' and each dependency you are installing.
Unknown option: '-extractionPath'
Chocolatey (v0.9.8.28) is installing 'c:\temp' and dependencies. By installing you accept the license for 'c:\temp' and each dependency you are installing.
Second path fragment must not be a drive or UNC name.
Parameter name: path2
Command 'install' failed (sometimes this indicates a partial failure). Additional info/packages: -extractionPath, c:\temp
Sorry, I am not sure that I follow what you mean...
What are you expecting that the parameter extractionPath
is used as the destination path when using the unzip chocolatey helper?
Gary
chocolateyInstall.ps1
$packageName = '{{PackageName}}'
$packageVersion = '{{PackageVersion}}'
$32BitUrl = '{{DownloadUrl}}'
$64BitUrl = '{{DownloadUrlx64}}'
$extractionPath = "c:\Program Files\Eclipse Foundation\$packageVersion"
Install-ChocolateyZipPackage "$packageName" "$32BitUrl" "$extractionPath" "$64BitUrl"
I was trying to overwrite the parameter $extractionPath while installing the package
I am still unclear about what you are asking for...
Does this help:
https://github.com/chocolatey/chocolatey/wiki/How-To-Parse-PackageParameters-Argument
Gary
This works. Thank you.
Would it be possible to create a function or something? I would like to use this for multiple packages. Is it possible to include this function in InstallChocolatey.ps1. What is your opinion regarding this?
If the installDir is overwritten then an issue could occur if the package will be uninstalled as the uninstallChocolatey function contains the default installDirectory as defined in the installChocolatey
For example, when an installer is run in Windows it is possible to define a installDirectory that is registered in the registry. Once the uninstaller is run, the installDiretory will be found in the registry and the package will be removed from that directory.
In this situation the installDirectory is modified, but once the uninstallChocolatey,ps1 script runs the default installDirectory will be removed. Should the installDirectory be registered on the system somewhere to avoid this issue?
Would it be possible to create a function or something? I would like to use this for multiple packages. Is it possible to include this function in InstallChocolatey.ps1. What is your opinion regarding this?
There is nothing to stop you adding additional ps1 files to your packages, and simply dot sourcing them for use within your chocolateyInstall.ps1 file. That way, you maintain your helper functions in one place, and use them across multiple packages. If you think that these helper functions are generic enough, then by all means, submit them as a pull request, and we can look into whether it makes sense to include them within Chocolatey core.
Is this a docs issue? I don't see this as a code issue. For matters such as this, it is a much better avenue to use the discussion list - chocolatey at googlegroups dot com.
Closed as a solution has been found
Closed as a solution has been found
For the benefit of others who might find this issue as the result of a search, could you share what you are now doing?
Gary
https://github.com/030/chocolateyautomatic/blob/master/common/Uninstall-ChocolateyZipPackage030.ps1 reads the installationZip file and removes the directory. If a custom path had been chosen this is registered in the file and by reading it the package will be removed from the correct location
Thank you! :-)