-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] The OS handle's position is not what FileStream expected. Do not use a handle simultaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss. #18
Comments
Is there a way to reproduce this? Does it only happen on a particular OS? And has it been verified on the newest choco with the newest provider rev? I recall a posh error in 2.0 related to this. I haven't tried it with the new shims, and some of the more recent changes. I have been meaning to switch the provider to powershell execution similar to the powershell and the wsus providers, instead of the bat files. That or the new shim method. |
We have a documented reproduction of this! http://pastebin.com/wz5peZbG Conversation is happening at https://groups.google.com/forum/#!msg/puppet-users/B2166yoTiD0/XS061RY8SFYJ |
Note that the user is/was on 0.9.8.20 and using the current forge module (0.0.2) |
Same error with v0.9.8.23 - http://pastebin.com/BFd90qkb |
Interesting, a google search turned up a few items. The important thing here is that it's a POSH v2 issue:
|
should this be handled in puppetprovider or in chocolatey.cmd does it not surface in v3? |
It might still be there in POSH v3, but I wasn't for sure when reading over the different comments. I haven't seen this on chocolatey itself, only when using the chocolatey provider. |
I'm pretty sure I might be able to reproduce this as simply as having a package that writes a good message then throws an error message. |
The following package tries to write to many streams: $packageName = 'badpackage'
try {
Write-Host "Ya!"
Write-Debug "A debug message"
Write-Warning "A warning!"
Write-Error "Oh no! An error"
throw "We had an error captain!"
Write-ChocolateySuccess "$packageName"
} catch {
Write-ChocolateyFailure "$packageName" "$($_.Exception.Message)"
throw
} package {'badpackage':
ensure => latest,
provider => chocolatey,
source => 'https://www.myget.org/F/killerpackages/'
} And I get the expected error (this issue):
|
ugh - thats harsh |
Basically if any package fails using the provider, boom shakalaka... and we have pipeline stoppage. |
And what's worse, you have no idea why it failed. |
I was slightly wrong there, we do have the error in the chocolateyInstall.log file.
|
boom shakalaka to killerpackages. lmao! I thought the powershell.exe calling via cmd was the culprit, and one of those links above with piping to out-default might be a workaround... |
From the possible workaround: http://www.leeholmes.com/blog/2008/07/30/workaround-the-os-handles-position-is-not-what-filestream-expected/ "This is bug in PowerShell, and happens when:
How does this work, and why does this happen in the first place? When PowerShell sends output to its output stream the first time, it keeps a reference to the output stream for future use. However, this output stream is really a wrapper around a lower-level stream. When cmd.exe writes to the output stream, it writes to the lower-level stream. This makes the .NET wrapper complain that the underlying stream has changed from beneath it." Puppet writes stdout and others out to a tempfile, which seems to be the cause of this - from looking at it a little further we are going to want to look into working around this. I tried chocolatey(*args, :combine => false, :failonfail => true) (thanks @joshcooper !) but on Windows it doesn't seem to gather the stderr stream for the output and believes the exit status was zero. It also doesn't log the output at all to |
Got the same problem with a package. I was able to install and uninstall the package manually by cmd and chocolatey commands. With puppet I was able to install the package. But when I tried to uninstall it I got the same error. The package is on a shared disk. Did the development of puppet module and chocolatey package on a VM on my laptop. On that VM I was able to install and uninstall the same package with puppet. The only diffrens between the servers was internet access. So I ran the uninstall on my VM with the network adapter disconnected. And the uninstallation failed. Does the chocolatey provider require internet access to be able to uninstall packages? |
Not that I know of. If you look at the chocolatey log you will likely see that it threw an error and powershell has a bug in it (v2, v3, and possibly v4) that causes it to puke because puppet is writing the log to a tmpfile and there is something written to any stream but stdout. I wrote a package that will show you this exact behavior. https://github.com/ferventcoder/nugetpackages/tree/master/badpackage |
does the package in question have a chocolateyuninstall.ps1 ? |
@ferventcoder any thoughts on how we can work around this bug? perhaps we look at using the ps1 via poweshell.exe passed as a command vs, the .cmd files? would that potentially alleviate the issue? |
Get out of powershell business as soon as possible. ;) |
in general, or for this? |
No I mean provide an executable. Less chance for issue if we are marshalling the output through that and then something like puppet is using that, it won't run into these errors. |
golang would be an interesting choice.
|
@jumanjiman :) I think we are going to start with something we know so we are not learning a language while trying to provide a working tool (I already did that once). |
hehe, that's the fun part :-) |
Yes as long as it is on a project that is not critical. :) |
Found the problem. Actually has nothing to do with this bug but gives the same error message. Then I ran command without internet: So I did a fix and tested it https://github.com/patant/puppet-chocolatey/blob/master/lib/puppet/provider/package/chocolatey.rb#L45-L47 Or perhaps it better to fix the exit code in chocolatey. |
i see this error from powershell provider as well... |
I just got the error with the tortoisegit package on a Windows 2008R2 VM. If I install it from the command line, all is good.
I have installed Powershell v3 via puppet and chocolatey believes it got installed. I will need further tests, since I fix too many things manually to get a clear view. FWIW, everything works very well on Windows 2012R2. |
I get this error when trying to install Chocolatey during vagrant (1.6.5, Ubuntu 14.04 host) provisioning of https://vagrantcloud.com/ferventcoder/boxes/win7pro-x64-nocm-lite - commenting out all occurences of Edit: at least I thought it did? A different workaround that also seems to work is doing |
Hopefully we are coming to an idea of where we are going with the choco.exe that should eliminate this. |
Well it seems that the ChocolateyInstall.ps1 was calling a .bat file specially on the rabbitmq chocolatey package https://chocolatey.org/packages/rabbitmq. I just repackaged and removed that .bat file and everything is working as expected. It seems that the ChocolateyInstall.ps1 allows you to do lots of things but i prefer to keep those in puppet for now. Otherwise, I will have to manage other logic inside my chocolatey packages. |
Agreed having a provisioner removes a need for packages to do as much. For those that would use those provisioners. If you are looking for a place to put those customized packages - https://github.com/ferventcoder/puppet-chocolatey-presentation/blob/master/demo/puppet/modules/chocolateyserver/manifests/init.pp |
I've had the same issue with Chocolatey v0.9.8.28 and the problem was the wrong name of the Chocolatey Install Function. There was a typo in it but could not figure it because it was always saying
I believe the exception message was not helpful. It should say something like
|
@lmayorga1980 it probably does, but this bug is annoying and doesn't tell you anything. However if you go over to the log that chocolatey creates you can find it just before it blows up. :/ The good news is that this goes away in about a month with the rewrite. |
Looking forward to the rewrite, because this bug is really causing me some grief at the moment :( |
Sorry to hear that. Yes it's a pain in the butt when it occurs. I'll be so glad when this doesn't happen anymore. |
I thought you were getting the error in powershell without ruby/cmd swallowing. |
@ferventcoder Just found out that there is a rewrite process going on. Hope the get an update when it happens. Digesting the turkey while typing this comment ... 😄 |
Should have an alpha version out next month. |
Are all powershell executions from puppet plagued by this if they do any stderr writing and puppet writes to its tmp? ie exec or other providers calling cmdlets, etc? Does these need to be reraised on cmsonnect or attention brought to some folks with influence at msft? |
All posh if it redirects output to a file and writes to more than one On Thursday, January 8, 2015, Rich Siegel [email protected] wrote:
Rob http://devlicio.us/blogs/rob_reynolds |
Definitely also running into this while running puppet -> boxstarter - > chocolatey |
This will close with #49 |
interestingly, I commented the write-host commands in the template here (InstallChocolatey.ps1.erb) and the errors went away on my clean win2008r2 box. PS 2.0. .net 4.0 note - i had no issues on 2012r2, or win2008r2 with .net 4.5 and wmf 4.0 I still have 1 more error later on. I think it comes from here-ish
|
…r/MODULES-3037-fixes (MODULES-3037) Confine install path fact w/default
I thought someone had already mentioned this issue before?
The text was updated successfully, but these errors were encountered: