chef-provisioning icon indicating copy to clipboard operation
chef-provisioning copied to clipboard

Files in Machine Resources fail to copy on windows when copied to drive root

Open geoffles opened this issue 8 years ago • 0 comments

When specifying files in a machine resource, I get the following error when the target file for the provisioned machine is in the root (eg: c:\myfile):

RuntimeError
    ------------
    Error: command 'New-Item -Type Directory -Force -Path "c:\"' exited with code 1.
    STDOUT: STDERR: #< CLIXML
    <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">New-Item : The path is not of a legal form._x000D__x000A_</S><S S="Error">At line:1 char:40_x000D__x000A_</S><S S="Error">+ $ProgressPreference='SilentlyContinue';New-Item -Type Directory -Force -Path _x000D__x000A_</S><S S="Error">"c: ..._x000D__x000A_</S><S S="Error">+
                        _x000D__x000A_</S><S S="Error">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : InvalidArgument: (C:\:String) [New-Item], Argume _x000D__x000A_</S><S S="Error">   ntException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShel _x000D__x000A_</S><S S="Error">   l.Commands.NewItemCommand_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>

I have narrowed this down to here: lib/chef/provisioning/transport/winrm.rb#L60

Basically, windows doesn't let you "create" c:\ so a check must be made to see that we're actually trying to make a sub dir before we create directories.

Workaround: Only use sub directories and do not target files to root.

geoffles avatar Aug 24 '16 13:08 geoffles