Closed Destroy666x closed 2 years ago
@Destroy666x The requirements of the install parameters :
If the registry key is found regardless of the parameters given. The install will be the location specified in the registry.
I hope this helps you out. I'm sure it is not what you would like for the answer. The helper script for this package could be re-done to be more informative or work differently.
The best suggestion is to uninstall the package. Reinstall to the desired location and future upgrades will be at that location.
@RedBaron2 sorry, but I'm not exactly sure how this helps me whatsoever... This seems completely unrelated to my report of not being able to change the install dir to one with space(s), for Cygwin package. I tried deleting that key and it still didn't install into the desired path.
Plus what you wrote seems like another bug, but one for uninstaller, which should delete that registry key I'd assume.
@Destroy666x Please take a moment and calmly let's look at this closely.
sorry, but I'm not exactly sure how this helps me whatsoever...
The code for the InstallDir detection reads the registry first. If that is found then any parameters of InstallDir are ignored.
I tried deleting that key and it still didn't install into the desired path.
Did you reboot the system after the change? *
Do not use force to install a package unless the package will not install normally. (Most packages don't need it)
Please follow the read me for this package closely.
If this package will not properly install using
choco install --params="/InstallDir:C:\Program Files\Cygwin"
then you can try
choco install --params="/InstallDir:%ProgramFiles%\Cygwin"
These are only suggestions and not to be the only ways to get the package un/installed.
@RedBaron2 yes, the registry was reloaded, few times by reboot specifically too for sure. Even if it wasn't, the initial problem didn't come out of nowhere, because, like I wrote, it keeps installing into C:\Program
, which means that it took my custom path, but an incorrect one... I can also install it to e.g. C:\Random
by just specifying C:\Random Files\Cygwin
Now these are kind of helpful:
Do not use force to install
Why is that exactly bad? I will try without, but I don't see why it would cause issues
choco install --params="/InstallDir:%ProgramFiles%\Cygwin"
I will try with that too, even though I have no idea what this would change as like I mentioned the direct plain text InstallDir
worked problemlessly for all the other packages that I wanted to moved. And, unsurprisingly:
So both commands you provided should be the same, right? Not too familiar with Windows command line, but envs should be parsed into text right when the command is executed or are they ignored in params between quotes?
Did you test this yourself and manage to install to that directory?
This is proof that --force
and registry don't matter:
Also, the uninstaller does remove the key from what I see. So you don't need to do it manually, I did last time because I probably didn't uninstall then.
@Destroy666x I'll do some more research, but the preliminary results are pointing to the cgywin setup not taking the spaces. They are being cut as of they are the end of the value not passed with the whole value. It though is Not the package or chocolatey.
I'll get back to you about it.
Ok thanks.
Env did also nothing like I suspected:
I'll try some more weird quote combinations in meanwhile, but I don't think anything can be achieved here without a fix somewhere.
EDIT: this dirty workaround worked after 2nd install, 1st results in error similar to the one I share in bug report, but complaining about "C
disk not existing: choco install cygwin --params="/InstallDir:'""C:\Program Files\Cygwin""'"
Any hints on how I'd quickly test a custom install script? Want to try my suggested fix from bug report, pretty sure it would work. Here's what I think happens with this command:
""
quotes regardless of it failing. Probably the .exe/.bat file inserts the env and then definitely this last line fails since the error is after Copying ...
debug line: https://github.com/chocolatey-community/chocolatey-coreteampackages/blob/master/automatic/cygwin/tools/chocolateyInstall.ps1#L55 $cygwin_root\cygwinsetup.exe
alo should be probably quotedSo @RedBaron2 , a short summary of last comment with what I'm guessing and 99% sure the fixes are, but I can't test that due to my insufficient Chocolatey knowledge at least yet:
$cygwin_root
needs to be between quotes in both lines$cygwin_root\cygwinsetup.exe
needs to be between quotes, not sure about $setup_path
@Destroy666x I'm still looking into this but can you answer a few questions
Though to answer your question of how to test your bug fix. The short list of events to do this are:
choco install Cgywin <whatever params> -s .
making sure you are in the same folder as the new nupkg file you created@Destroy666x I believe you are correct in your assumption that the space issue is caused by the package not explicitly quoting the paths (chocolatey's helper trims out the quotes you pass to it).
However, to be completely sure before we make any necessary changes to that area, would you be able to provide the full log of the installation?
This log is located in %ChocolateyInstall%\logs\chocolatey.log
, in this file we can see both the arguments that chocolatey received as well as the arguments that get passed to the cygwin installer (feel free to clean up that log with any values you deem sensitive).
@RedBaron2
C:\Program FIles\Cygwin
or D:\Some tools\Cygwin
. But, to answer, that's where I normally installed Cygwin with a regular installer, so just a habit@AdmiringWorm sure, any specific commands you'd like it for? Or just any command that doesn't work?
@Destroy666x any log related to a command that is failing should suffice.
The install
command with a path containing spaces would probably be the best.
@AdmiringWorm ok, so here are logs of both choco install cygwin --force --params "/InstallDir:C:\Program Files\Cygwin"
installation attempts, 1st that fails with the error and 2nd with success but installation to wrong path:
As it can be seen, the paths required by the installer are sent without quotes: --root C:\Program Files\Cygwin --local-package-dir C:\Program Files\Cygwin
Then, after Copying cygwin package manager (setup) to C:\Program Files\Cygwin
, you can see the error from the last code lines of installer script.
@AdmiringWorm @Destroy666x
I tested the standard way to install with the normal --params="/InstallDir:C:\Program Files\Cygwin"
. Chocolatey sees and passes the params to the installer Correctly. The Problem is in the passed arguments to the Native Setup file. The Native Setup needs to have the arguments with Spaces enclosed in quotes. (I mentioned this earlier)
This is not a problem of Chocolatey reading the params Wrong, but it is a problem of the Native Setup needing to be Double Quoted to see the params Correctly
The lines 30 and 31 need to be changed to
"--root ""$cygwin_root"" " "--local-package-dir ""$cygwin_root"" "
as mentioned my @Destroy666x earlier and tested out here
None of these changes will fix the last line of the Cygwin package line 55
that fails because of the $ErrorActionPreference = 'Stop'
at line 1
changing this to be `$ErrorActionPreference = 'SilentlyContinue'
fixes the fail to pass
I hope this helps you all out. If @AdmiringWorm would like a PR to make the changes please let me know.
The other way of implementing these without waiting on a PR is to use the following
choco install Cygwin --installargs='--root ""C:\Program Files\Cygwin"" --local-package-dir ""C:\Program Files\Cygwin"" '
@RedBaron2 the reason why those changes fail, is due to it being invalid unfortunately, the correct approach would be change the lines to:
"--root `"$cygwin_root`""
"--local-package-dir `"$cygwin_root`""
The two characters `"
tells PowerShell to escape the double quote, but using ""
can unfortunately not be used in this context.
changing this to be
`$ErrorActionPreference = 'SilentlyContinue'
fixes the fail to pass
That unfortunately doesn't really fix anything, it just ignores the error but would cause a bug to happen instead.
I hope this helps you all out. If @AdmiringWorm would like a PR to make the changes please let me know.
Feel free, and we can take it from there. Please only make the changes to that PR that is necessary to fix this issue though. May also want to do the quoting for the site, proxy and the public key as well (just to be sure).
I assume noone is working on a PR, so I'll do one soon
@Destroy666x AFAIK, there is no one that works on this issue, so feel free. I'll assign the issue to you in the meantime.
This is now fixed in the repository, and a new fix version of the package is queued to be pushed to Chocolatey Community Repository.
I would like to install Cygwin into
C:\Program Files\Cygwin
. Commands I tried:choco install cygwin --force --params "/InstallDir:C:\Program Files\Cygwin"
choco install cygwin --force --params "/InstallDir:""C:\Program Files\Cygwin"""
choco install cygwin --force --params "'/InstallDir:C:\Program Files\Cygwin'"
choco install cygwin --force --params "/InstallDir:'C:\Program Files\Cygwin'"
choco install cygwin --force --packageparameters="/InstallDir:C:\Program Files\Cygwin"
And some other variants/combinations of these I can't exactly recall.Expected Behavior
Cygwin should install to path with spaces like
C:\Program Files\Cygwin
like many other packages do, e.g. PHP or Python didn't have this issue.Current Behavior
Currently it's acting weirdly because there are 2 possible outcomes:
C:\Program
incorrectlyPossible Solution
I'm pretty sure there is something wrong with Cygwins installation file, but not much knowledge from me on these. Possibly these not being quoted? https://github.com/chocolatey-community/chocolatey-coreteampackages/blob/master/automatic/cygwin/tools/chocolateyInstall.ps1#L30-L31 ¯_(ツ)_/¯
Steps to Reproduce (for bugs)
Context
Installation of Cygwin in a different folder to keep the system more clean.
Your Environment