Vagrant: How to sync folders from guest back to host?


kakat

Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)?

So please can someone guide me in this case:

  • Need to work on a project. This is the git repo. Requires mysql, php, etc.
  • VM is great (provided)
  • However, editing files in this repository via ssh and "legacy" editors is not easy. Want to use your favorite IDE.

in the VM repository /home/vagrant/src. I want it to be visible/editable ../srcin the host .

I read the documentation and put this in Vagranfile:

config.vm.synced_folder '../src', '/home/vagrant/src'

This "works" except that it will overwrite all content from /home/vagrant/srcand those from ../srcwhich are empty.

Any workaround? I considered the possibility of cloning the repository via git (publicly available via github) and syncing the folder to the VM, but that doesn't feel right, and also loses the production configuration.

VK

Mine Vagrantfilelooks like this:

Vagrant.configure(2) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network :forwarded_port, guest: 22, host: 10170, id: "ssh"
  config.vm.provision :shell, path: "VagrantProvision.sh"
  config.vm.synced_folder "./", "/var/beeGame"
end

As you can see, my statement is the same as yours! Here is my repo (you can try it like an example) and it worked for me! I use PhpStorm to open this repository and edit the files and all updates automatically and sync from the host (laptop) to the guest (virtual).

In your case , you're doing everything right, and vagrant has to overwrite all the content /home/vagrant/srcwith those from ../src. This is correct behavior! ! ! You need to put your code in srca directory on the host machine (laptop), not on the guest machine (virtual machine)!

Related


Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

Vagrant Rsync does not sync folders between host and guest

Yusuf Ibrahim| Vagrant Rsync doesn't work and gives me the following error: $ vagrant.exe rsync-auto ==> default: Doing an initial rsync... ==> default: Rsyncing folder: /cygdrive/d/OS/vweb-project/project/web-project/ => /web-project ==> default: Watching:

Vagrant - How to access guest Postgres server from host

Horse O'Houlihan I installed a boring box with a postgres server running on a port 5432and added it to Vagrantfile: config.vm.network "private_network", ip: "192.168.33.33" config.vm.network "forwarded_port", guest: 5432, host: 3333 But when I try to conn

Vagrant - How to access guest Postgres server from host

Horse O'Houlihan I installed a boring box with a postgres server running on a port 5432and added it to Vagrantfile: config.vm.network "private_network", ip: "192.168.33.33" config.vm.network "forwarded_port", guest: 5432, host: 3333 But when I try to conn

Vagrant - How to access guest Postgres server from host

Horse O'Houlihan I installed a boring box with a postgres server running on a port 5432and added it to Vagrantfile: config.vm.network "private_network", ip: "192.168.33.33" config.vm.network "forwarded_port", guest: 5432, host: 3333 But when I try to conn

Vagrant - How to access guest Postgres server from host

Horse O'Houlihan I installed a boring box with a postgres server running on a port 5432and added it to Vagrantfile: config.vm.network "private_network", ip: "192.168.33.33" config.vm.network "forwarded_port", guest: 5432, host: 3333 But when I try to conn

Vagrant - How to access guest Postgres server from host

Horse O'Houlihan I installed a boring box with a postgres server running on a port 5432and added it to Vagrantfile: config.vm.network "private_network", ip: "192.168.33.33" config.vm.network "forwarded_port", guest: 5432, host: 3333 But when I try to conn

Vagrant sync folder missing from guest machine

march I'm trying to configure a virtual machine with synced folders to the directory I'm Vagrantfilein (should be the default behavior, but it doesn't work). Here is my Vagrantfile in its current state (see bootstrap.shbelow): # -*- mode: ruby -*- # vi: set ft

Set ENV variable from host to guest in Vagrant

Romeo Michalcia Is there any way to set some ENV variables on boot from host to guest Vagrant OS? From the guest OS, I need to connect to the database and I want to pass the database URL from the host to the guest along with other parameters. I tried that, TES

Set ENV variable from host to guest in Vagrant

Romeo Mihalcea Is there any way to set certain ENV variables from the host to the guest Vagrant OS when starting the host? From my guest OS, I need to connect to the database and I want to pass the database URL from the host to the guest along with other param

Set ENV variable from host to guest in Vagrant

Romeo Mihalcea Is there any way to set certain ENV variables from the host to the guest Vagrant OS when starting the host? From my guest OS, I need to connect to the database and I want to pass the database URL from the host to the guest along with other param

VirtualBox: How to sync host and guest time?

Kunitaka The time in my guest VM is about 20-30 minutes faster than the host time. What can I do so that the time in the guest is the same as the time on the host? Nikita Krupenko For Linux hosts, first install the DKMS (Dynamic Kernel Module Support) package

VirtualBox: How to sync host and guest time?

Kunitaka The time in my guest VM is about 20-30 minutes faster than the host time. What can I do so that the time in the guest is the same as the time on the host? Nikita Krupenko For Linux hosts, first install the DKMS (Dynamic Kernel Module Support) package

How to use NFS for vagrant sync specific folders?

Kim Stacks Host: OS X Mavericks Guest computer: Ubuntu 14.04 VM software: VirtualBox 4.3.14 In my Vagrantfile I have the following and it works fine: config.vm.synced_folder "~/Documents/WebApps", "/var/virtual/WebApps", id: "vagrant-root", owner: "www-

How to use NFS for vagrant sync specific folders?

Kim Stacks Host: OS X Mavericks Guest computer: Ubuntu 14.04 VM software: VirtualBox 4.3.14 In my Vagrantfile I have the following and it works fine: config.vm.synced_folder "~/Documents/WebApps", "/var/virtual/WebApps", id: "vagrant-root", owner: "www-

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to

How to sync files from a Docker container back to its host?

Zolt Maybe I'm complicating this. My goal is to create a Docker based workflow for Node.js application development on Windows. During development I will be able to run my app locally inside the container and still easily see the latest version (I don't want to