ndbroadbent / turbo-sprockets-rails3

Speeds up your Rails 3 assets:precompile by only recompiling changed files, and only compiling once to generate all assets
MIT License
975 stars 78 forks source link

file permission error on utime #36

Closed jhchen closed 11 years ago

jhchen commented 11 years ago

When i try to push using capistrano I get a file permission error. I've chmod'd the file and parent folder to 777 just in case but still the same issue. Any ideas or things I can try? If I ssh'd myself and run assests:precompile it works fine.

* executing "cd /opt/stypi/releases/20121128024558 && bundle exec rake RAILS_ENV=beta RAILS_GROUPS=assets assets:precompile" servers: ["beta.stypi.com"] [beta.stypi.com] executing command * [out :: beta.stypi.com] rake aborted! * [out :: beta.stypi.com] * [out :: beta.stypi.com] Operation not permitted - /opt/stypi/releases/20121128024558/public/assets/alert-overlay.png * [out :: beta.stypi.com] * [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:80:in utime' ** [out :: beta.stypi.com] ** [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:80:inblock in internal_precompile' * [out :: beta.stypi.com] * [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:77:in each' ** [out :: beta.stypi.com] ** [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:77:ininternal_precompile' * [out :: beta.stypi.com] * [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:108:in block (3 levels) in <top (required)>' ** [out :: beta.stypi.com] ** [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:34:ininvoke_or_reboot_rake_task' * [out :: beta.stypi.com] * [out :: beta.stypi.com] /opt/stypi/shared/bundle/ruby/1.9.1/gems/turbo-sprockets-rails3-0.3.2/lib/turbo-sprockets/tasks/assets.rake:49:in `block (2 levels) in <top (required)>' * [out :: beta.stypi.com] * [out :: beta.stypi.com] Tasks: TOP => assets:precompile:all * [out :: beta.stypi.com] * [out :: beta.stypi.com](See full trace by running task with --trace) \ [out :: beta.stypi.com] command finished in 20379ms

glanotte commented 11 years ago

I ran into this also, this appears to be a bit deeper than just ruby. Apparently in order to update the timestamps on a file, you need to be the owner, regardless of permissions. You could also perform the operation as root. Perhaps someone else might have a better solution, but in order to work around this I set a before and after task in capistrano to change the owner of the assets directory and all files inside to the deployer and then after I changed it back to the user who runs the rails app.

jhchen commented 11 years ago

Ok the setting permissions before and after works for me too. Thanks!

ndbroadbent commented 11 years ago

Hi @jhchen and @glanotte, sorry I haven't responded until now. I've pushed a new version which should solve the issue without needing to set permission before and after. A non-owner still has permission to update the asset's mtime to the current time, so I've replaced File.utime with a shell touch command. It would be great if you could help me test this with your deployments. Thanks!

griffindy commented 11 years ago

I'm getting a similar error at this line, namely right when non digest assets are being copied. I also solved it by chowning the directory before asset compilation. Can this also be solved using touch instead?

jgyllen commented 11 years ago

@ndbroadbent Is that fix in 0.3.6?

I'm having the same problem as @griffindy and the only way to solve it is chowning the whole assets folder before deploy:assets:precompile.

erikj commented 10 years ago

as others have reported above, this issue persists: I am also encountering it in 0.3.11 due to https://github.com/ndbroadbent/turbo-sprockets-rails3/blob/master/lib/sprockets/static_non_digest_generator.rb#L56:

File.utime(File.atime(abs_digest_path), mtime, abs_logical_path)
djmaze commented 7 years ago

Problem still persists, this change fixes it. Can somebody make a PR?