When using collision-protect, there is an os.chdir(srcroot) before each merge. Since this directory is destroyed soon after the merge, it can lead to an error message, like in this example: [...] >>> Completed installing into /var/tmp/portage/unison-2.10.2/image/ * checking 9 files for package collisions * spend 0.17255282402 seconds checking for file collisions >>> Merging net-misc/unison-2.10.2 to / [...] >>> net-misc/unison-2.10.2 merged. net-misc/unison selected: 2.9.1-r1 protected: 2.10.2 omitted: none >>> 'Selected' packages are slated for removal. >>> 'Protected' and 'omitted' packages will not be removed. >>> Waiting 5 seconds before starting... >>> (Control-C to abort)... >>> Unmerging in: 5 4 3 2 1 >>> Unmerging net-misc/unison-2.9.1-r1... No package files given... Grabbing a set. shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory [...] An easy "fix" to avoid this error message is to save the cwd before the chdir, and restore it after the collision checking. A patch follows.
Created attachment 40441 [details, diff] portage.py--collision-protect_restore_cwd.patch
Possibly in parallel, but marius fixed this a while back.