#1003 rm -r ../testdir fails to remove testdir

closed-fixed
MSYS (75)
2007-09-02
2007-01-27
No

The following recursive rm invocation fails to remove the top-level directory. The failure appears to be linked somehow with a '..' in the directory name.

$ mkdir test
$ cd test
$ mkdir ../testdir
$ touch ../testdir/testfile
$ du -a ..

0 ../test
0 ../testdir/testfile
0 ../testdir
0 ..

$ rm -r ../testdir
rm: cannot remove directory `../testdir': No such file or directory
$ du -a ..

0 ../test
0 ../testdir
0 ..

$ rm --version
rm (GNU coreutils) 5.97
$ /bin/ls -l /bin/rm
-rwxr-xr-x 1 cstrauss Administradores 37888 Jan 20 00:27 /bin/rm

System info:
Windows XP Home SP 2
MinGW installer: manual (tar -zxf)
$ uname -a
MINGW32_NT-5.1 CESAR 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys
MinGW runtime version: 3.11
w32api version: 3.8

Discussion

1 2 > >> (Page 1 of 2)
  • Earnie Boyd

    Earnie Boyd - 2007-01-27
    • status: open --> open-duplicate
     
  • Earnie Boyd

    Earnie Boyd - 2007-01-27

    Logged In: YES
    user_id=15438
    Originator: NO

    I thought I fixed that all ready. There is a closed ticket for this same error.

     
  • Earnie Boyd

    Earnie Boyd - 2007-01-27

    Logged In: YES
    user_id=15438
    Originator: NO

    Sorry, this is different. The difference is the .. directory but is probably related to the other issue.

     
  • Earnie Boyd

    Earnie Boyd - 2007-01-27
    • status: open-duplicate --> open
     
  • Earnie Boyd

    Earnie Boyd - 2007-01-27
    • assigned_to: earnie --> cstrauss
     
  • Earnie Boyd

    Earnie Boyd - 2007-01-27

    Logged In: YES
    user_id=15438
    Originator: NO

    Cesar will you take a look please? The change I made before was to ensure that the directory level had changed back to the starting point before trying to remove the last directory entry. The recurse points didn't back up to remove the last directory before my change so the directory was still open and being windows it can't remove or rename an open directory. You should be able to determine the diff from the CVS. TIA, Earnie.

     
  • Cesar Strauss

    Cesar Strauss - 2007-01-27

    A solution for the rm -r problem

     
  • Cesar Strauss

    Cesar Strauss - 2007-01-27

    Logged In: YES
    user_id=1369729
    Originator: YES

    Hello, Earnie

    You are right, the issues are related. The attached patch solves both cases. I don't think your fix addressed the core of the matter, however, so I also reverted it in my patch.

    I suspect the MSYS version of fchdir may not be working correctly, instead. It is used for changing to the original working directory, as the final directory is removed. The fchdir call is in lib/save-cwd.c (restore_cwd).

    There was already a fallback using file names instead of descriptors, so I used that.

    The next thing to do would be making a test case against fchdir and possibly filling a bug report. However, I will travel on vacation, starting tomorrow, so expect a one week delay.

    Cesar

    File Added: rm-r.patch

     
  • Earnie Boyd

    Earnie Boyd - 2007-02-13

    Logged In: YES
    user_id=15438
    Originator: NO

    Cesar, I've not had time to look. Do you think you can manage a snapshot update? Make sure that your MSYS libraries are built with ``-s -O2 -mcpu=pentium'' and make sure that you build the coreutils package with the same switches. I typically will set the afore mentioned flags in a variable ccflags and then on then do ``make CFLAGS="$ccflags" CXXFLAGS="$ccflags"''. Ping me at my SF address if you need help.

     
  • Cesar Strauss

    Cesar Strauss - 2007-02-14

    Logged In: YES
    user_id=1369729
    Originator: YES

    Earnie wrote:
    > Do you think you can manage a snapshot update?

    Sure.

    >Make sure that your MSYS libraries are built with ``-s -O2
    >-mcpu=pentium'' and make sure that you build the coreutils package
    >with the same switches.

    Done. I will place the snapshot at an accessible location soon.

    Cesar

     
  • Earnie Boyd

    Earnie Boyd - 2007-02-14

    Logged In: YES
    user_id=15438
    Originator: NO

    Not somewhere, load it to the MSYS Snapshot using the FRS technique. Use ``ftp uploads.sf.net'', ``cd incoming'', ``put'' the file. Then do the file releases under the admin menu above. Let me know if you need help.

     
  • pachiburke

    pachiburke - 2007-05-10

    Logged In: YES
    user_id=1790157
    Originator: NO

    Even after upgrading to the latest MsysCore and later to the coreutils snapshot (2007-02-05) I'm still having problems with 'rm -rf' not being able to work fine.

    $ rm -v --version
    rm (GNU coreutils) 5.97
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software. You may redistribute copies of it under the terms of
    the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
    There is NO WARRANTY, to the extent permitted by law.

    Written by Paul Rubin, David MacKenzie, Richard Stallman, and Jim Meyering.

    $ make clean
    find . -name "*~" -or -name "*.sw?" -or -name "*.pyc" -exec rm {} ';'
    rm -rf Site/Local/*
    rm: cannot remove directory `Site/Local/album': No such file or directory
    rm: cannot remove `Site/Local/cirugia': No such file or directory
    rm: cannot remove `Site/Local/consejos': No such file or directory
    rm: cannot remove `Site/Local/consulta': No such file or directory
    rm: cannot remove `Site/Local/curriculum': No such file or directory
    rm: cannot remove `Site/Local/dossier': No such file or directory
    rm: cannot remove `Site/Local/faq': No such file or directory
    rm: cannot remove `Site/Local/favicon.ico': No such file or directory
    rm: cannot remove `Site/Local/hemeroteca': No such file or directory
    rm: cannot remove `Site/Local/img': No such file or directory
    rm: cannot remove `Site/Local/index-en.htm': No such file or directory
    rm: cannot remove `Site/Local/index-fr.htm': No such file or directory
    rm: cannot remove `Site/Local/index-pt.htm': No such file or directory
    rm: cannot remove `Site/Local/index.htm': No such file or directory
    rm: cannot remove `Site/Local/main.css': No such file or directory
    rm: cannot remove `Site/Local/noticias': No such file or directory
    rm: cannot remove `Site/Local/opinion': No such file or directory
    rm: cannot remove `Site/Local/web': No such file or directory
    make: *** [clean] Error 1

    $ msysinfo
    msysinfo-1.3: Send this to the MSYS support list:

    MSYS 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 unknown; targ=MINGW32
    GNU bash, version 2.04.0(1)-release (i686-pc-msys); ENV=.profile
    GNU Make version 3.79.1,Built for i686-pc-msys; MAKE_MODE=unix
    gcc.exe (GCC) 3.4.2 (mingw-special); targ=MINGW32
    GNU ld version 2.15.91 20040904
    4 2007-01-12 21:00:58.000000000 +0000 /bin/msys-1.0.dll
    4 2003-01-02 06:05:27.000000000 +0000 /bin/msysltdl-3.dll
    0 2003-06-30 13:20:16.000000000 +0000 /mingw/bin/make.exe
    2004-09-21 09:15:22.000000000 +0000 /mingw/bin/gcc.exe
    8 2004-09-05 00:45:43.000000000 +0000 /mingw/bin/ld.exe
    HOME=/home/pachi
    Sysname=MINGW32_NT-5.1 OSTYPE=msys TERM=cygwin
    PATH=.:/usr/local/bin:/mingw/bin:/bin:/c/winp/GTK/bin:/c/WINDOWS
    /system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/winp/Mercurial:
    /c/winp/gtk/2.0/lib:/c/winp/OpenSSH:/c/winp/OpenSSH/bin:/c/winp/
    bin:/c/winp/OpenOffice.org_2.0_SDK/windows/bin:/c/winp/OpenOffic
    e.org 2.0/program:/c/winp/PuTTY:/c/winp/python24:/c/winp/python2
    4/Scripts:/c/winp/Vim/vim70/:/c/winp/Mercurial:/c/winp/upx

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-11
    • status: open --> pending
     
  • Cesar Strauss

    Cesar Strauss - 2007-05-11

    Logged In: YES
    user_id=1369729
    Originator: YES

    Thanks for testing the snapshots.

    Please, try this:

    mkdir -p a/b/c
    rm -rf a/b/*

    Does it fails? If it does, it means your upgrade failed, somehow, and you still have the old bugged version.

    Please, make sure you downloaded the latest coreutils package. It has the exact same name as the version it replaced, so you may need to clear your browser's cache. Here is the md5sum output:

    8a18fe1d5f8f706da8519dd77b10efa2 *coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz

    And for rm.exe:

    d907a9463a1960266029bb1da6f779c9 */bin/rm.exe

    Regards,
    Cesar

     
  • pachiburke

    pachiburke - 2007-05-11

    Logged In: YES
    user_id=1790157
    Originator: NO

    It's very weird, as it doesn't work either, but I seem to have that same versions, both for the coreutils and the rm binary:

    $ mkdir temp
    $ cd temp
    $ mkdir -p a/b/c
    $ rm -rf a/b/*
    rm: cannot remove directory `a/b/c': No such file or directory
    $ which rm
    /mingw/bin/rm.exe
    $ md5sum.exe /mingw/bin/rm.exe
    d907a9463a1960266029bb1da6f779c9 */mingw/bin/rm.exe
    $ md5sum.exe /e/temp/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2
    8a18fe1d5f8f706da8519dd77b10efa2 */e/temp/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-13

    Logged In: YES
    user_id=1369729
    Originator: YES

    > $ which rm
    > /mingw/bin/rm.exe

    Please try this:

    $ /mingw/bin/rm.exe -rf a/b/*

    If it works, try this:

    $ hash -r
    $ mkdir -p a/b/c
    $ rm -rf a/b/*

    You seem to have unpacked the coreutils in the MinGW root. You may consider installing coreutils in the MSYS root, instead.

    Cesar

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-13
    • status: pending --> open
     
  • Anonymous - 2007-05-13

    Logged In: YES
    user_id=1791930
    Originator: NO

    I have also had this same problem with rm -rf for as long as I can remember. I've been using the latest snapshot with the exact same md5sum's cstrauss mentioned.

    $ mkdir test
    $ rm -rf test
    rm: cannot remove directory `test': No such file or directory
    $ rm -rf test/*
    $ ls -l
    drwxr-xr-x 2 Main Administrators 0 May 13 00:52 test

    Adding the /* stopped it from complaining but that's because it's a different command that works on nothing (no subdirectories of test). As you can imagine this cramps and/or breaks some Makefiles and configure scripts and is becomingly increasingly irritating. I find it unlikely that every user of mingw has this problem. Could there be some insidious corruption in my filesystem?

     
  • pachiburke

    pachiburke - 2007-05-13

    Logged In: YES
    user_id=1790157
    Originator: NO

    No luck :(. It doesn't work either using the full path and only a one depth dir.

    $ which rm
    /mingw/bin/rm.exe
    $ mkdir -p a/b/c
    $ /mingw/bin/rm.exe -rf a/b/*
    /mingw/bin/rm.exe: cannot remove directory `a/b/c': No such file or directory
    $ hash -r
    $ mkdir -p a/b/c
    $ rm -rf a/b/*
    rm: cannot remove directory `a/b/c': No such file or directory
    $ hash -r
    $ /mingw/bin/rm -rf a/b/*
    rm: cannot remove directory `a/b/c': No such file or directory
    $ /mingw/bin/rm -rf a/b/c
    rm: cannot remove directory `a/b/c': No such file or directory

    To add some more information that could be relevant, I'm using a FAT32 partition on that drive, and I didn't have that problem with an old msys install. It all began with the upgrade to the new release and persists with the snapshot.

     
  • Anonymous - 2007-05-13

    Logged In: YES
    user_id=1791930
    Originator: NO

    Thanks for the tip about the old rm.exe working. I fixed my problem by copying the old version of rm.exe from MSYS-1.0.10 into /bin. It works!

    $ rm --version
    rm (fileutils) 4.1
    $ md5sum /bin/rm.exe
    bf4e6ad10d15e8f4b50dbce241d2bace */bin/rm.exe
    $ mkdir testdir
    $ rm -rf testdir
    $ ls

    No more testdir! My configure and Makefiles now work cleanly.

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-13

    Logged In: YES
    user_id=1369729
    Originator: YES

    Hello, superdma and pachiburke.

    Please try the modified version of rm.exe which is attached below, in the "attached files" section.

    Strangely, I also started getting this behaviour:

    $ mkdir test
    $ rm -rf test
    rm: cannot remove directory `test': No such file or directory

    I am not yet sure what triggered it, but I think I was able to work around it.

    Regards,
    Cesar

    File Added: rm.exe

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-13

    Workaround for rm -rf testdir not removing testdir

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-13

    Workaround for rm -rf testdir not removing testdir (patch)

     
  • Cesar Strauss

    Cesar Strauss - 2007-05-13

    Logged In: YES
    user_id=1369729
    Originator: YES

    File Added: getcwd.patch

     
  • Anonymous - 2007-05-13

    Logged In: YES
    user_id=1791930
    Originator: NO

    tried the new rm.exe and it works!

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks