I had this same issue when working on a Rails 6 application in Ubuntu 20.04.
Each time I run the command rails assets:clobber
to remove the old assets in public/assets
completely, I get the error:
errno::enotempty: directory not empty @ dir_s_rmdir
errno::eacces: permission denied @ apply2files
And the logs pointed the path to the file causing it, which in my a case was the public/packs/manifest.json
file.
I tried deleting it or changing permission but nothing worked. I also tried deleting the tmp
directory in the project, but it did not work.
Here's how I fixed it:
I listed all the files and directories in that directory using the ls -lh
command, which gave me this output:
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 1.7K Oct 6 20:29 404.html
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 1.7K Oct 6 20:29 422.html
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 1.6K Oct 6 20:29 500.html
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 0 Oct 6 20:29 apple-touch-icon.png
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 0 Oct 6 20:29 apple-touch-icon-precomposed.png
drwxr-xr-x 3 promisechukwuenyem promisechukwuenyem 4.0K Oct 13 09:20 armstrong_tools
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 0 Oct 6 20:29 favicon.ico
drwxr-xr-x 3 root root 4.0K Oct 8 13:06 packs
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 99 Oct 6 20:29 robots.txt
I realized that the packs
directory had root
ownership which was seperate from persmission of other files and directories:
drwxr-xr-x 3 root root 4.0K Oct 8 13:06 packs
I simply ran the command below to change the ownership from root to promisechukwuenyem:
sudo chown -R promisechukwuenyem:promisechukwuenyem packs/
Now when I ran the command rails assets:clobber
to remove the old assets in public/assets
completely, it worked just fine.
That's all.
I hope this helps
uglifier
toterser
for JS compression. I had to runrails assets:clobber
in Staging/Production and then re-deploy and everything was fine. – Burlingame