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

sync_folder leads to "syntax error" report for vagrant builder #9564

Closed
john-forrest opened this issue Jul 11, 2020 · 10 comments · Fixed by #9577
Closed

sync_folder leads to "syntax error" report for vagrant builder #9564

john-forrest opened this issue Jul 11, 2020 · 10 comments · Fixed by #9577
Labels

Comments

@john-forrest
Copy link

Overview of the Issue

I am trying to use the vagrant builder with virtualbox instead of the "classic approach" of building ubuntu or whatever from the iso image. This seemingly works until I try and use sync_folder to map a host folder into my environment. I can see this in the doc, although have yet to see what claims to be a working example, so could be I am missing something. If it were that I was missing something, that would imply the doc could be updated.

I suspect the error is coming from vagrant but I am assuming the issue is in packer for now - difficult to tell.

Issue seen is:
vagrant: strconv.Atoi: parsing "": invalid syntax

Mergely removing the "sync_folder" entry removes this issue, but of course does not map the folder as required.

Reproduction Steps

I've cut this down from my original to a fairly simple (I believe) example.

  • See attached .zip file and unzip.
  • Go to directory problem-packer2
  • Run: packer build --only=vagrant --force --on-error=abort vagrant-builder-example.json

Packer version

Packer v1.6.0

Simplified Packer Buildfile

{
"builders": [
{
"type": "vagrant",
"communicator": "ssh",
"source_path": "ubuntu/bionic64",
"add_force": true,
"provider": "virtualbox",
"box_name": "problem",
"synced_folder": "foo"
}
],
"provisioners": [
{
"type": "shell",
"scripts": ["scripts/basic_install.sh"]
}
]
}

Operating system and Environment details

Vagrant 2.2.9
Virtual Box 6.1
Windows 10 1909

Log Fragments and crash.log files

==> vagrant: Deleting previous output directory...
==> vagrant: Creating a Vagrantfile in the build directory...
==> vagrant: Adding box using vagrant box add ...
vagrant: (this can take some time if we need to download the box)
==> vagrant: Calling Vagrant Up (this can take some time)...
==> vagrant: strconv.Atoi: parsing "": invalid syntax
==> vagrant: Step "StepSSHConfig" failed, aborting...
==> vagrant: aborted: skipping cleanup of step "StepUp"
==> vagrant: aborted: skipping cleanup of step "StepAddBox"
==> vagrant: aborted: skipping cleanup of step "StepCreateVagrantfile"
==> vagrant: aborted: skipping cleanup of step "StepOutputDir"
Build 'vagrant' errored: strconv.Atoi: parsing "": invalid syntax

==> Some builds didn't complete successfully and had errors:
--> vagrant: strconv.Atoi: parsing "": invalid syntax

==> Builds finished but no artifacts were created.

@john-forrest
Copy link
Author

Forgot to attach .zip
problem-packer2.zip

@SwampDragons
Copy link
Contributor

I can only reproduce this if the "foo" directory doesn't exist, and then when I enable verbose logging I see:

2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stdout: Bringing machine 'source' up with 'virtualbox' provider...
2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stderr: There are errors in the configuration of this machine. Please fix
2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stderr: the following errors and try again:
2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stderr:
2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stderr: vm:
2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stderr: * The host path of the shared folder is missing: foo
2020/07/14 11:25:58 packer-builder-vagrant plugin: [vagrant driver] stderr:
2020/07/14 11:25:58 packer-builder-vagrant plugin: Calling Vagrant CLI: []string{"ssh-config", "source"}
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: The provider for this Vagrant-managed machine is reporting that it
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: is not yet ready for SSH. Depending on your provider this can carry
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: different meanings. Make sure your machine is created and running and
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: try again. Additionally, check the output of `vagrant status` to verify
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: that the machine is in the state that you expect. If you continue to
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: get this error message, please view the documentation for the provider
2020/07/14 11:26:00 packer-builder-vagrant plugin: [vagrant driver] stderr: you're using.
==> vagrant: destroying Vagrant box...```

@SwampDragons
Copy link
Contributor

I'll add prepare() code to stat this path and make sure it exists

@john-forrest
Copy link
Author

Is the path relative to the vagrant output folder, so where the Vagrantfile will be, or the packer template?

@SwampDragons
Copy link
Contributor

Hm, I just gave the absolute path. In most of our other conventions relative path should be relative to the folder you run Packer from, so I'll check my fix to make sure it also expects that.

@john-forrest
Copy link
Author

If I change the entry to "../foo" that works, but that is relative to the Vagrantfile and not what I'd expect.

@SwampDragons
Copy link
Contributor

I'll fix that now.

@SwampDragons
Copy link
Contributor

ok pushed an updated patch to document how relative paths should work, and make it so the expected relative path is relative to the folder running packer not the vagrantfile folder.

@SwampDragons
Copy link
Contributor

@ghost
Copy link

ghost commented Aug 15, 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 Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants