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

Upgrade to Rails 4.1 broke autoreload using NFS with a VirutalBox VM #16678

Closed
benedictfischer09 opened this issue Aug 24, 2014 · 15 comments
Closed

Comments

@benedictfischer09
Copy link

Hi I'm using Vagrant to run a Rails app on a VirtualBox Ubuntu VM, and sharing a directory between the host and guest over NFS.

I upgraded a Rails 3.2 app to Rails 4.1 and auto-reloading stopped working. I tested this with a simple Rails 4.1 demo app that you can see here https://github.com/benedictfischer09/reload_problem Looks like auto reloading doesn't work with Rails 4.1 and this VM setup (I didn't test 4.0).

I opened a SO question but it hasn't seen much attention so I figured I'd open an issue here too http://stackoverflow.com/questions/25451327/rails-4-1-doesnt-autoreload-on-vagrant-vm

@seuros
Copy link
Member

seuros commented Aug 24, 2014

I think it has to do with your NFS/Vagrant settings.

@benedictfischer09
Copy link
Author

Autoreloading worked with the settings for Rails 3.2 though which is the only reason I consider this a Rails issue. Do you know of a different way to set up the VM to get autoreloading working with Rails 4.1?

@shorrockin
Copy link

Experiencing the same issue on a very recent rails 4 upgrade running inside a vagrant ubuntu vm. I've noticed that autoreload does appear to function, but takes about ~3 minutes to pick up any change. Was also running rails 3.2 before, and everything was peachy.

@noinkling
Copy link
Contributor

May or may not be related: I have issues with Guard (in polling mode) picking up changes consistently using Vagrant and Virtualbox (w/ shared folders) and Rails 4.1 (with Spring both enabled and disabled). The files get updated fine, the changes just don't get detected half the time.

@rafaelfranca
Copy link
Member

It can still be a problem on vagrant. We didn't changed anything in the code reloader feature between Rails 3 and Rails 4. The only thing in our side that I could think is spring.

I'm not a vagrant user and I think most of core member are not so I'd recommend you do investigate the problem or this issue will be open for some months until our bot mark it as stale and close.

@rafaelfranca
Copy link
Member

This may be one of the reasons. 20519ef and 65dc45e.

Check if both vagrant box and local machine have the same time.

@shorrockin
Copy link

thanks for the input @rafaelfranca - i can confirm that in my scenario, sync'ing the clocks between the host operating system and vagrant did in fact resolve the issue. cheers!

@rafaelfranca
Copy link
Member

Thank you for confirming. Closing.

@ghost
Copy link

ghost commented Mar 12, 2015

Thank you so much!!! I've been poking around this for a few days!

@axsuul
Copy link
Contributor

axsuul commented Jun 18, 2015

I ran into this issue and solved it with this in my Vagrantfile

# Sync time every 5 seconds so code reloads properly
config.vm.provider :virtualbox do |v|
  v.customize ["guestproperty", "set", :id, "--timesync-threshold", 5000]
end

@pangloss
Copy link

pangloss commented Nov 4, 2015

The workaround @axsuul posted worked for me. Thanks very much!

@rdyson
Copy link

rdyson commented Mar 2, 2016

@axsuul Thanks for the workaround, worked for me.

@3den
Copy link

3den commented Apr 8, 2016

I have this same problem on docker, it reloads fine for everything except controllers.

@ctammes
Copy link

ctammes commented Apr 8, 2016

The same here, with docker.
I develop on a PC (Ubuntu 14.04) that has internet time. I deploy to a VM in the company network that runs docker. Deployment is done through the VM to the docker container, that runs the WEBrick server. Both VM and container have the same time, but my desktop is about 8 minutes ahead.
No problems with changes in a view, but the controller behaves weird:

class VimeoController < ApplicationController
  flauwekul
  ldfdasl;f
  ;lasdfasldf
 end

When I deploy this code, I get errors. I comment it out, deploy again and the errors are gone. Immediately afterwards I remove the comments, deploy again, and still no errors.

Rails 4.2.6
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
WEBrick 1.3.1

@ctammes
Copy link

ctammes commented Apr 8, 2016

I think I figured it out, at least my problem.
It is caused by the fact that my desktop time is ahead of the VM/container time. If time is in the future, it is displayed as a year, see examples from the container (the file has just been deployed from the desktop):

date
Fri Apr  8 14:03:43 CEST 2016

ls -l
-rw-rw-r-- 1 1001 1001  151 Apr  8  2016 vimeo_controller.rb

ls --full-time
-rw-rw-r-- 1 1001 1001  151 2016-04-08 14:11:40.000000000 +0200 vimeo_controller.rb

The real time, however, is present in the file and can be seen with --full-time. When the VM/container reaches the real filetime, the file is refreshed.
So there must be a problem somewhere in calculating the time when deciding when to refresh. The only thing that matters for a refresh is whether the new filetime differs from the old.

It is as described in 65dc45e, but I don't think it is abnormal as is said in the comment. It will happen often when communicating with a remote server and you are not always in a position to change remote server time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants