provision error: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

provision error: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log

Rui Lopes
For some reason I'm getting the following error:

==> test: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log: The process cannot access the file
==> test: 'C:\Windows\Temp\WinRM_Elevated_Shell.log' because it is being used by another process.
==> test: At C:\tmp\vagrant-elevated-shell.ps1:19 char:3
==> test: +   del $out_file
==> test: +   ~~~~~~~~~~~~~
==> test:     + CategoryInfo          : WriteError: (C:\Windows\Temp\WinRM_Elevated_Shell.log:FileInfo) [Remove-Item], IOExcepti
==> test:    on
==> test:     + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand

My Vagrantfile has something like:

    config.vm.provision "shell", inline: "c:/tmp/provision/install-a.ps1", name: "Install a"
    config.vm.provision "shell", inline: "c:/tmp/provision/install-b.ps1", name: "Install b"

The error happens when its trying to run the second provision script.

Looking at https://github.com/mitchellh/vagrant/blob/master/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb it seems that the scheduled task that is created by the first provision script is somehow still running... is that it? if so how can that happen when elevated_shell.ps1.erb is checking (while (!($registered_task.state -eq 3))) is still running? Maybe that check is not enough? Maybe it should really wait for the task to close the log file?

TIA!

PS Host and Guest is Windows 10 64-bit. Vagrant is 1.8.4. VirtualBox is 5.0.24r108355.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/e39c2b51-389c-429c-8702-389ddd4fcf0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: provision error: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log

Rui Lopes
On Thursday, July 14, 2016 at 7:21:30 PM UTC+1, Rui Lopes wrote:
For some reason I'm getting the following error:

==> test: del : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log: The process cannot access the file
==> test: 'C:\Windows\Temp\WinRM_Elevated_Shell.log' because it is being used by another process.
==> test: At C:\tmp\vagrant-elevated-shell.ps1:19 char:3
==> test: +   del $out_file
==> test: +   ~~~~~~~~~~~~~
==> test:     + CategoryInfo          : WriteError: (C:\Windows\Temp\WinRM_Elevated_Shell.log:FileInfo) [Remove-Item], IOExcepti
==> test:    on
==> test:     + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand

My Vagrantfile has something like:

    config.vm.provision "shell", inline: "c:/tmp/provision/install-a.ps1", name: "Install a"
    config.vm.provision "shell", inline: "c:/tmp/provision/install-b.ps1", name: "Install b"

The error happens when its trying to run the second provision script.

Looking at <a href="https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fblob%2Fmaster%2Fplugins%2Fcommunicators%2Fwinrm%2Fscripts%2Felevated_shell.ps1.erb&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNHngoARhIMqXaTztl9h5iqqgigy5A" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fblob%2Fmaster%2Fplugins%2Fcommunicators%2Fwinrm%2Fscripts%2Felevated_shell.ps1.erb\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHngoARhIMqXaTztl9h5iqqgigy5A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fblob%2Fmaster%2Fplugins%2Fcommunicators%2Fwinrm%2Fscripts%2Felevated_shell.ps1.erb\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHngoARhIMqXaTztl9h5iqqgigy5A&#39;;return true;">https://github.com/mitchellh/vagrant/blob/master/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb it seems that the scheduled task that is created by the first provision script is somehow still running... is that it? if so how can that happen when elevated_shell.ps1.erb is checking (while (!($registered_task.state -eq 3))) is still running? Maybe that check is not enough? Maybe it should really wait for the task to close the log file?


That was it! I've modified the elevated_shell.ps1.erb to https://github.com/mitchellh/vagrant/pull/7584 :-)

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a99ac197-0a57-4436-bb11-4aff75ee234d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.