Why would chmod give "No such file or directory" when running recursively?

This bug looks related:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=706097

I can reproduce it in debian 7 with coreutils 8.13-3.5.

I think that not using "--changes" or "--verbose" can workaround the problem.


I just had this happen to me this week when using --verbose. Was initially puzzled but think I have narrowed it down. This only happens when the SETGID bit is set.

Test setup:

$ mkdir --parent foo/bar

Without SetGID, no error:

$ chmod --recursive --changes o-rwx foo
mode of ‘foo’ changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---)
mode of ‘foo/bar’ changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---)

With SETGID, error:

$ chmod --recursive g+s foo
$ chmod --recursive --changes o-rwx foo
mode of ‘foo’ changed from 2775 (rwxrwsr-x) to 2770 (rwxrws---)
chmod: getting new attributes of ‘bar’: No such file or directory

As a workaround, use find:

$ find foo | xargs chmod --changes o-rwx
mode of ‘foo’ changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---)
mode of ‘foo/bar’ changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---)

Hope this helps!