Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files don't update in vagrant when saved on host computer?

I'm using Vagrant as a Rails development environment. I only use the host computer to edit the files in sublime text (i.e. Ruby, Rails, Postgres and Nginx are all on the vagrant vm).

The problem is that if I make a small change in a file (1-3 characters), refreshing the browser doesn't show the update right away. I have to either restart nginx or add a few empty lines and save again to see the update.

What might be causing this? I've tried everything under the sun to resolve this.

Here is my vagrant file:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "xyz.box"
  config.vm.box_url = "http://domain.com/xyz.box"

  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.synced_folder ".", "/vagrant", :nfs => true

  config.vm.provider "virtualbox" do |vb|
    vb.customize [
      "modifyvm", :id,
      "--memory", "1024",
      "--natdnsproxy1", "on",
      "--natdnshostresolver1", "on"
    ]
  end
end

I'm on Mac OS X and using Virtual Box as the provider. The vagrant box is Ubuntu 14.04.

like image 308
Jacob Avatar asked Dec 17 '25 11:12

Jacob


2 Answers

It turned out the problem was Sublime Text's default "atomic save" feature that was creating this problem.

Adding the following to your Sublime Text preferences file will fix this:

"atomic_save": false

like image 152
Jacob Avatar answered Dec 19 '25 07:12

Jacob


This is a known problem for Apache and nginx with Virtualbox -- so also vagrant (@see this vagrant issue). The sendfile kernel mode does not refresh on the shared disk folders.

To fix it use this on nginx configuration:

sendfile off
like image 20
regilero Avatar answered Dec 19 '25 06:12

regilero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!