When working with an ebuild where some directories created under ${HOME} had the writable bits removed, I found that it triggered a PermissionError in shutil.rmtree. Then problem is easily demonstrated as follows: > $ mkdir -p /tmp/foo/bar/baz > $ chmod a-w /tmp/foo/bar/baz /tmp/foo/bar > $ python3.7 > Python 3.7.0 (default, Feb 20 2019, 18:25:13) > [GCC 7.3.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import shutil > >>> shutil.rmtree('/tmp/foo') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/lib/python3.7/shutil.py", line 485, in rmtree > _rmtree_safe_fd(fd, path, onerror) > File "/usr/lib/python3.7/shutil.py", line 423, in _rmtree_safe_fd > _rmtree_safe_fd(dirfd, fullname, onerror) > File "/usr/lib/python3.7/shutil.py", line 427, in _rmtree_safe_fd > onerror(os.rmdir, fullname, sys.exc_info()) > File "/usr/lib/python3.7/shutil.py", line 425, in _rmtree_safe_fd > os.rmdir(entry.name, dir_fd=topfd) > PermissionError: [Errno 13] Permission denied: 'baz' Though this issue could apply to all shutil.rmtree calls, it's most problematic when removing files/directories created by random processes, like in prepare_build_dirs where it attempts to cleanup the temporary ${HOME} dir.
Similar issue with gitea-1.9.5, ebuild gitea-1.9.5.ebuild prepare clean results in lots of messages like: > rm: cannot remove '/var/tmp/portage/www-apps/gitea-1.9.5/work/gitea-1.9.5/pkg/mod/github.com/nfnt/resize@v0.0.0-20160724205520-891127d8d1b5/LICENSE': Permission denied > rm: cannot remove '/var/tmp/portage/www-apps/gitea-1.9.5/work/gitea-1.9.5/pkg/mod/github.com/nfnt/resize@v0.0.0-20160724205520-891127d8d1b5/.travis.yml': Permission denied