0

I am using this vagrant box to test out a python script I am working on

    config.vm.box = "mcandre/vagrant-ubuntu-python3"

Project root in host machine is c:/pythontest Vagrantfile is in this root

    c:/pythontest/Vagrantfile

I placed my python script test.py in c:/pythontest which is by default shared with guest /vagrant

    c:/pythontest/test.py

For the changes I make in IDE in host machine are not reflecting in guest.

Steps I followed I make changes in the script save the script check the changes in terminal from guest maching using cat

However if I reload vagrant box ( vagrant reload ) , I can see the changes.

I tried below options

    config.vm.synced_folder "./", "/vagrant"

`

    config.vm.synced_folder "c:/pythontest", "/vagrant"

I get this in output when I up the box ( vagrant up )

    ==> default: Rsyncing folder: /cygdrive/c/pythontest/ => /vagrant

Here is all the output

    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Checking if box 'mcandre/vagrant-ubuntu-python3' is up to date...
    ==> default: Clearing any previously set forwarded ports...
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 (guest) => 2222 (host) (adapter 1)
    ==> default: Running 'pre-boot' VM customizations...
    ==> default: Booting VM...
    ==> default: Waiting for machine to boot. This may take a few minutes...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
    ==> default: Machine booted and ready!
    ==> default: Checking for guest additions in VM...
    ==> default: Rsyncing folder: /cygdrive/c/datascience/ => /vagrant
    ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
    ==> default: flag to force provisioning. Provisioners marked to run always will still run.

Can you please help me autosync these changes I make from host machine?

Thanks

KA.
  • 4,220
  • 5
  • 26
  • 37

1 Answers1

0

You're using the vagrant rsync shared folder type so as mentioned in doc

The rsync synced folder does a one-time one-way sync from the machine running to the machine being started by Vagrant.

The rsync and rsync-auto commands can be used to force a resync and to automatically resync when changes occur in the filesystem. Without running these commands, Vagrant only syncs the folders on vagrant up or vagrant reload.

If you do one-time change, you can run the vagrant rsync command to make sure your change is sync in the VM.

If you do frequent changes on the host, you should run the vagrant rsync-auto, it will detect changes on the host and sync on the VM.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139