Aaron Ransley

Aaron Ransley

This technique can resolve issues with Rails 5 applications running inside Docker on Windows 10. This solution might help if you're receiving these sorts of errors:

Errno::EEXIST at / File exists @ dir_s_mkdir - tmp/cache/assets/sprockets/v3.0/Pd

Steps to Resolve

1) Add the following bits to ~/docker-compose.yml:

volumes:
  cache: # Added to support Windows 10 Docker
services:
  app:
    volumes:
      - cache:/cache # Added to support Windows 10 Docker
    environment:
      - SPROCKETS_CACHE=/cache # Added to support Windows 10 Docker

2) Introduce a custom Sprockets cache path during asset initialization in ~/config/initializers/assets.rb:

Rails.application.config.assets.configure do |env|
  env.cache = Sprockets::Cache::FileStore.new(
    ENV.fetch("SPROCKETS_CACHE", "#{env.root}/tmp/cache/assets"),
    Rails.application.config.assets.cache_limit,
    env.logger
  )
end

3) Sprockets errors should dry up.