Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerized Rails 5 RC1 application not picking up updates to controllers and models in development

I have quite a bit of experience developing Rails 4 apps on Mac OS X + Docker Machine + Docker Compose, but something has changed with how Rails 5 is caching files in the development environment (currently testing with RC1).

After starting the application with docker-compose up, the application runs normally in development mode.

But if I make a change to a controller or model, the only way I can get that reflected in the application is to stop the server and start it back up.

So now my workflow looks something like this when I need to make a change to a controller or model:

  1. Make change to controller/model class.
  2. Stop server with Ctrl + C.
  3. Start server back up with docker-compose up.
  4. Wait on the server to start up.
  5. Run whatever I was running in the browser.

To say the least, needing to do steps 2-4 is annoying and not what I'm accustomed to from Rails 4.

I went a step further and uninstalled Spring using the Removal instructions, but I still get the same behavior.

I also searched for any settings that I could find in config/environments/development.rb related to the Rails runtime's iron grip on the model and controller classes, and I couldn't find anything. (I assume that it really wants to rely on watching the filesystem in order to selectively load changes, and something isn't being picked up from a change on Mac to VirtualBox.)

Any other ideas on what I can try? Or are there any new settings related to how this more aggressive caching works?

like image 360
Chris Peters Avatar asked May 10 '16 16:05

Chris Peters


1 Answers

I'm Using Rails 5 rc1.

Rails 5 introduced some "improvements" to code reloading, but it doesn’t seem to work with Docker on OS X.

So in config/environments/development.rb, I replaced

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

with

config.file_watcher = ActiveSupport::FileUpdateChecker

It seems that for the ActiveSupport::EventedFileUpdateChecker file watcher, the change event does not occur for docker-machine shared files

like image 78
mdkrog Avatar answered Oct 22 '22 03:10

mdkrog