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

permission denied with capistrano on releases cleanup for cache directory #43

Open piotrmasior opened 11 years ago

piotrmasior commented 11 years ago

after adding gem 'turbo-sprockets-rails3' Capistrano gives me strange error on releases cleanup task (permission denied)

after little investigation:

lets@staging:~/www/releases$ ls
20121216144703  20121218165946  20121218171035
lets@staging:~/www/releases$ cd 20121216144703
lets@staging:~/www/releases/20121216144703$ ls -la
total 12
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 .
drwxrwxr-x 5 lets lets 4096 2012-12-18 16:04 ..
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 tmp
lets@staging:~/www/releases/20121216144703$ cd tmp/
lets@staging:~/www/releases/20121216144703/tmp$ ls -la
total 12
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 .
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 ..
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 cache
lets@staging:~/www/releases/20121216144703/tmp$ cd cache/
lets@staging:~/www/releases/20121216144703/tmp/cache$ ls -la
total 12
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 .
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 ..
drwxrwxr-x 6 lets lets 4096 2012-12-17 12:23 assets
lets@staging:~/www/releases/20121216144703/tmp/cache$ cd assets/
lets@staging:~/www/releases/20121216144703/tmp/cache/assets$ ls -la
total 24
drwxrwxr-x 6 lets lets 4096 2012-12-17 12:23 .
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 ..
drwxrwxr-x 3 root root 4096 2012-12-16 09:50 D41
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 D43
drwxrwxr-x 3 lets lets 4096 2012-12-17 12:23 D6A
drwxrwxr-x 3 root root 4096 2012-12-16 09:50 DDB

this is how directory looks like after failed Capistrano command for cleanup.

healthy(old) release has got at least 40 directories... and always only 2 of them has got different group permissions (root:root instead of lets:lets)

the question is ... why? or at least what is possible scenario for that

ps. not occurring when I remove gem, so definitively it is gem malfunction (or just unusal configuration from server side)

pss. I was so happy when I discovered your gem :dancers: (deploy is 90% time quicker) good job

best

ndbroadbent commented 11 years ago

Hi, thanks for the bug report!

It looks like your rake assets:precompile task must be running as the root user, and the error is probably caused by this line: https://github.com/ndbroadbent/turbo-sprockets-rails3/blob/master/lib/turbo-sprockets/tasks/assets.rake#L82.

Does your deploy script do anything special with permissions, or changing groups?

piotrmasior commented 11 years ago

no it does nothing with permissions...

cap staging shell

whoami

returns 'lets' properly

I am digging into it currently, and now I am confused because just after deploy all permissions are good... and it seems to be cache generated by unicorn first hit :/ Only from gmpas4rails gem ^^

so probably it is not problem from your gem (directly) but problem appeared since I added it... maybe just coincidence

will close temporarily as invalid probably

ps .. it is funny because my staging config has got:

config.assets.compile = false

best

piotrmasior commented 11 years ago

ok ... not sure how your gem impacts dynamic compile/cache but certainly it is the problem

My environment run over root user via unicorn (and it is my fault - I will change that for sure)

but that cause the problem... and I can imagine cases when someone uses 'unicorn user' different than 'capistrano user'

without gem that problem never exists as my environment doesn't create any files during execution...

dunno why environment creates funny cache folders after adding your gem, that line with 'touch' command in rake script doesn't explain it (or if does I am not following that)

best