From: Jim Meyering Date: 2006-10-05T01:25:00+09:00 Subject: making FileUtils.rm_rf robust: is anyone interested? Hello, I see that FileUtils.rm_rf cannot handle a tree containing a relative names longer than PATH_MAX. These commands create a hierarchy a/0...0/0...0/... where the name specifying the deepest directory has length 4097. That is usually greater than PATH_MAX. ( mkdir a && cd a && for i in $(seq 16); do d=$(printf %0255d 0); mkdir $d && cd $d; done ) This shows that rm_rf doesn't remove "a": ruby -r fileutils -e 'FileUtils.rm_rf("a")' test -d a && echo failed to remove a It prints this: failed to remove a It is not at all trivial to fix this "properly". By "properly," I mean in a way that rm_rf can remove an arbitrarily deep hierarchy securely while remaining efficient and thread safe. Modulo hard-coded diagnostics, the C implementation in the GNU coreutils package (src/remove.c) should be appropriate. Jim