vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

"vm.synced_folder" Does not create if non-existent

Open ajshastri opened this issue 4 years ago • 1 comments

Vagrant version: 2.2.19

Host operating system: Windows 10

Guest operating system: Oracle Linux 7

Vagrantfile

Vagrant.configure("2") do |config|

  config.vm.define "base" do |base|
    base.vm.box = "oraclelinux/7-btrfs"
    base.vm.network :forwarded_port, guest: 22, host: 22556, id: 'ssh'
    base.vm.hostname = "oraclelinux7.localhost.localdomain"
    base.vm.synced_folder "./provision", "/vagrant"

      base.vm.provider "virtualbox" do |vb, override|
          vb.cpus = 2
          vb.memory = 1024
          vb.gui = false
          vb.name = 'oraclelinux7'
          override.vm.synced_folder "./provision", "/vagrant"

          # disable the vbguest update plugin
          if Vagrant.has_plugin?("vagrant-vbguest")
              override.vbguest.auto_update = false
          end
      end
    end
end

Debug output

Gist URL

Expected behavior

Folder is created if not existent with the vm.synced_folder command according to Synced Folders - Basic usage

Actual behavior

Error if the folder does not exist

vm:
* The host path of the shared folder is missing: ./provision

Steps to reproduce

  1. Install the Vagrantfile as described above.
  2. Run vagrant up

References

https://www.vagrantup.com/docs/synced-folders/basic_usage

ajshastri avatar Dec 02 '21 19:12 ajshastri

Note that the host folder is not created by default, you need to add create: true option (which is false by default):

-     base.vm.synced_folder "./provision", "/vagrant"
+    base.vm.synced_folder "./provision", "/vagrant", create: true

https://www.vagrantup.com/docs/synced-folders/basic_usage#create

I believe that the issue can be closed.

mrzasa avatar May 19 '22 07:05 mrzasa