I really have no idea why I am having troubles with cyg-get. It talks about not being able to find a file, but it seems clearly to be present.
I installed choco+cygwin+cyg-get on another machine just hours before this happened. The only difference I can think of is that Cygwin used to be manually installed before trying to install it through Choco.
This is the output straight after installing choco and opening a new admin terminal:
PS C:\Windows\system32> choco install cyg-get
Installing the following packages:
cyg-get
By installing you accept licenses for the packages.
Cygwin v2.4.1
The package Cygwin wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider setting
'allowGlobalConfirmation'. Run 'choco feature -h' for more details.
Do you want to run the script?
1) yes
2) no
3) print
1
Downloading Cygwin 64 bit
from 'https://cygwin.com/setup-x86_64.exe'
Installing Cygwin...
Starting cygwin install, version 2.873
User has backup/restore rights
Current Directory: C:\ProgramData\chocolatey
Could not open service McShield for query, start and stop. McAfee may not be installed, or we don't have access.
root: C:\cygwin64 system
Selected local directory: C:\ProgramData\chocolatey
net: Direct
site: http://mirrors.kernel.org/sourceware/cygwin/
Changing gid back to original
running: C:\cygwin64\bin\dash.exe "/etc/postinstall/0p_000_autorebase.dash"
running: C:\cygwin64\bin\dash.exe "/etc/postinstall/0p_update-info-dir.dash"
Changing gid to Administrators
Ending cygwin install
Cygwin has been installed.
The install of cygwin was successful.
cyg-get v1.2.1
The package cyg-get wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider setting
'allowGlobalConfirmation'. Run 'choco feature -h' for more details.
Do you want to run the script?
1) yes
2) no
3) print
1
Adding C:\ProgramData\chocolatey\bin\cyg-get.bat and pointing it to powershell command C:\ProgramData\chocolatey\lib\cy
g-get\tools\cyg-get.ps1
The install of cyg-get was successful.
Chocolatey installed 2/2 package(s). 0 package(s) failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32> cyg-get openssh
Attempting to install cygwin packages: openssh
C:\ProgramData\chocolatey\lib\cyg-get\tools\cyg-get.ps1 : Please ensure you have Cygwin installed.
To install please call 'choco install cygwin' (optionally add -y to autoconfirm).
ERROR: This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ & 'C:\ProgramData\chocolatey\lib\cyg-get\tools\cyg-get.ps1' openssh
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,cyg-get.ps1
PS C:\Windows\system32>
This will be fixed by PR #125, if that gets merged.
Change the value of $cygwinsetup to the following $cygwinsetup = "$cygRoot\setup-x86_64.exe" in cyg-get.ps1 file
@tlin-fei : Thanks for the input, but observe my comment above: there is already a pending PR that will fix this issue. I just applied the patch to fix my problem.
I'm having this problem too, and the latest cygwin (v2.5.0) does not seem to have setup-x86_64.exe or cygwinsetup.exe
@tadeu I found a workaround for this issue (tested with cygwin 2.5.0)
@cwiggs your workaround works for me too!
cwiggs workaround solved my issue

@cwiggs thanks for posting. Just installed fresh today and still having the same issue your work around fixed it.
I am still having issues. tried the fix suggested by @cwiggs but did not work. Any suggestions ..?

@dwbimstr I had the same issue.
I started by removing cyg-get and cygwin, then choco install cyg-get -y (note that I left out cygwin)
then I followed @cwiggs steps. I then was able to
cyg-get openssh
But now I don't know how to install sshd as a service after that. Can anyone offer suggestions?
Side note, I'm really surprised this issue is still present a year later. Wouldn't this be just a simple matter of checking if 32 or 64 bit and downloading the correct installer?
This cyg-get script is badly written.
I suggest people remove try / except block and see why it actually fails. While the cygwin package was recently changed to ensure setup is on right location, this is probably some other type of error.
I solved this problem by completely removing Cygwin, deleting registry keys HKLM:\SOFTWARE\Cygwin\setup and HKLM:\SOFTWARE\Wow6432Node\Cygwin\setup (removing Cygwin should remove the former), and then reinstalling Cygwin and cyg-get.
In my case, the cause of the problem was that one of the registry keys HKLM:\SOFTWARE\Cygwin\setup and HKLM:\SOFTWARE\Wow6432Node\Cygwin\setup pointed to an invalid Cygwin root path and script cyg-get.ps1 was using the one which was invalid, preventing it from finding Cygwin. The Chocolatey Cygwin package creates registry key HKLM:\SOFTWARE\Cygwin\setup, but not HKLM:\SOFTWARE\Wow6432Node\Cygwin\setup, so an earlier installation of the regular Cygwin setup must have created this key.
Most helpful comment
@tadeu I found a workaround for this issue (tested with cygwin 2.5.0)