Reputation: 183519
Our Heroku-hosted Rails 4 public asset directory (~/public/assets
) is polluted with multiple versions of compiled assets, including ones we deleted long ago. I can't figure out how to get rid of them- it's driving me nuts. Tried:
heroku run rake assets:clean
heroku run rake assets:clobber
~/public/assets/
directory, but as soon as I re-login with another bash session they're still there!Upvotes: 2
Views: 291
Reputation: 520
Ok, guys. I now understand the problem and just in case it helps someone else:
You can not delete files via heroku run bash
the way you would expect. This is by design. Have a look here: https://devcenter.heroku.com/articles/how-heroku-works#dyno-manager
The important thing to notice:
This [
heroku run bash
] will spin up a new dyno
...
Changes to the filesystem on one dyno are not propagated to other dynos and are not persisted across deploys and dyno restarts.
Ok, that explains it. So, what if you can't get rid of old assets and rake assets:clobber
doesn't solve it? Well, maybe something is hiding in cache.
This solved it for me:
Hope this helps ;)
Upvotes: 2
Reputation: 4465
Since heroku is precompiling your asset files on production, there is nothing much you can do since heroku has a ephemeral file system.
According to Heroku
Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted.
So every change that you make on heroku's file system gets wiped out.
Upvotes: 0