Skip to content
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

Windows file provisioner fails with "The path is not of legal form" #7435

Closed
dragon788 opened this issue Jun 13, 2016 · 9 comments
Closed

Windows file provisioner fails with "The path is not of legal form" #7435

dragon788 opened this issue Jun 13, 2016 · 9 comments

Comments

@dragon788
Copy link
Contributor

dragon788 commented Jun 13, 2016

Vagrant version

Vagrant 1.8.1

Host operating system

Windows 7 Enterprise

Guest operating system

Windows 2012r2

Vagrantfile

Using the Vagrantfile under development directory in this repository https://github.com/mefellows/vagrant-dsc.git

The failing line is:

  # Upload Website
  config.vm.provision "file", source: "website", destination: "C:\\MyWebApp"

It is attempting to recursively upload the website directory (really only 1 file) into this destination after creating it, but it fails to perform the create. Changing this to not include the drive as part of the path works, but it shouldn't fail if a drive is included as well.

Failure output

==> default: Running provisioner: file...
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir C:\ -force

Stdout from the command:



Stderr from the command:

#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">mkdir : The path is not of a legal form._x000D__x000A_</S><S S="Error">At line:2 char:1_x000D__x000A_</S><S S="Error">+ mkdir C:\ -force_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>

Expected behavior

It should have created the folder and uploaded the files.

Actual behavior

It fails to create the folders and therefore the vagrant up fails. It appears that the syntax for mkdir differs between cmd and Powershell, and when running through WinRM the command runs as Powershell. In Powershell mkdir is recursive, so it will create the entire path defined in one call, rather than having to mkdir -p or loop over the folders precreating each level.

Steps to reproduce

  1. Using a Windows 2012r2 evaluation build a box with chocolatey preinstalled (https://github.com/dragon788/windows has an example)
  2. Add box to system as win2012r2
  3. Modify Vagrantfile to remove mfellows/ from config.vm.box.
  4. vagrant up and see if you get the same failure.

References

Perhaps similar to #7234

@sethvargo
Copy link
Contributor

Hi @dragon788

This looks suspiciously like mefellows/vagrant-dsc#14. Can you try the solutions on there?

@mefellows
Copy link

Sorry to say @sethvargo, looking at the error above it's a separate issue. mefellows/vagrant-dsc#14 is to do with an issue with the upstream DSC resources (which have since been fixed). To me, it looks like the files (DSC resources and manifests) are unable to be synced into the guest, and there PowerShell is unable to see the DSC modules.

It may still be an issue with the plugin of course, but definitely a different issue.

@dragon788
Copy link
Contributor Author

Still running into this issue and having a failure on the file provisioner. This doesn't appear to be directly related to the vagrant-dsc plugin as it should be using the core file provisioner still.

@chrisroberts chrisroberts added this to the 1.8 milestone Oct 3, 2016
@magnussuther
Copy link

As dragon788 says, "changing this to not include the drive as part of the path works", i.e:

box.vm.provision "file", source: "../../scripts/", destination: "scripts"

However the file/directory won't end up in C:\ as you might expect, but rather in C:\Users\Administrator.

One might use
box.vm.provision "shell", inline: "Move-Item C:/Users/Administrator/scripts/ C:/scripts"
to move the file/dir into the correct place.

@chrisroberts
Copy link
Member

Hi there,

It looks like this has been resolved within a previously shipped version of Vagrant so I am now closing this issue. If the original issue was not fully resolved, please reopen this issue or create a new one.

Cheers!

@petemounce
Copy link

petemounce commented Jun 14, 2017

I now have this problem with vagrant 1.9.5 running against a Windows 2012r2 host. I've tried

  config.vm.provision "file" do |f|
    f.source = "s:/infra/puppet/"
    f.destination = "c:\\puppet"
  end
  config.vm.provision "file" do |f|
    f.source = "s:/infra/puppet/"
    f.destination = "c:/puppet"
  end

and the error is

λ  vagrant provision --provision-with file
==> default: Running provisioner: file...
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir c:\ -force

Stdout from the command:



Stderr from the command:

The path is not of a legal form.
At line:1 char:1
+ mkdir c:\ -force
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (C:\:String) [New-Item], ArgumentException
    + FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

@buffcode
Copy link

buffcode commented Jul 4, 2017

Using Vagrant 1.9.6 on Windows 10 Pro x64, using WinRM to connect to a Windows 10 x64 Enterprise image:

Configuration:

config.vm.communicator = "winrm"
config.vm.provision "file", source: "./.windows/setup.ps1", destination: "C:\\destination\\"

Output:

==> default: Running provisioner: file...
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir C:\ -force

Stdout from the command:



Stderr from the command:

The path is not of a legal form.
At line:1 char:1
+ mkdir C:\ -force
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (C:\:String) [New-Item], ArgumentException
    + FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

Process finished with exit code 1

@santljvr
Copy link

Hi,

I was setting up the vagrant and I got this issue during the vagrant setup

error 9 , tmp\tools\provisioner\provision_utils.py mkdir(self.__manifes['id']) is too long

I found the file was in the vagrant\provisioning\scripts\provisioner\provision_utils.py and i commented the erroneous lines. will it cause any issue later.

#if os.path.exists(TMP_PATH + "/" + self.__manifest['id']) == False:
#os.mkdir(TMP_PATH + "/" + self.__manifest['id'])
#if os.path.exists(TMP_PATH) == False:
#os.mkdir(TMP_PATH)

@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants