GNU bug report logs - #29205
--force doesn't work

Previous Next

Package: coreutils;

Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>

Date: Wed, 8 Nov 2017 09:36:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29205 in the body.
You can then email your comments to 29205 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#29205; Package coreutils. (Wed, 08 Nov 2017 09:36:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Konstantin Kharlamov <hi-angel <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 08 Nov 2017 09:36:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: bug-coreutils <at> gnu.org
Subject: --force doesn't work
Date: Wed, 8 Nov 2017 12:35:32 +0300
Steps to reproduce:

1. $ mkdir -p foo/bar/buzz1
2. $ mkdir -p bar/buzz2
3. $ mv --force bar foo/

Expected result: "bar" is merged into the other "bar"
Actual result: error "mv: cannot move 'bar' to 'foo/bar': Directory not 
empty"

I am experiencing this the second time on this week, it's a real 
problem. I'm building a package from a source code, but then it fails 
because it's another buggy app, so I'm doing "mv 
/tmp/yaourt-blahblha/package-name ~/Projects" set out to see if I can 
fix the code, and send patches.

But then "mv" fails, because Archlinux's `makepkg` is in its turn buggy, 
and leaves bad permissions on `pkg` dir inside the code.

So I'm removing this dir, and trying to continue `mv`ing, and here we 
coming to the bug I'm reporting.

Of course I could just copy, but `mv`ing is α) much faster, and β) 
leaves dates of file creation in places, so I don't need to rebuild the 
whole thing over again, only the files I gonna change.




Information forwarded to bug-coreutils <at> gnu.org:
bug#29205; Package coreutils. (Tue, 30 Oct 2018 02:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 29205 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>, 29205 <at> debbugs.gnu.org
Subject: Re: bug#29205: --force doesn't work
Date: Mon, 29 Oct 2018 20:01:09 -0600
tags 29205 notabug
close 29205
stop

(triaging old bugs)

It seems your message was lost and not replied to in a year.
Sorry about that.

On 2017-11-08 2:35 a.m., Konstantin Kharlamov wrote:
> Steps to reproduce:
> 
> 1. $ mkdir -p foo/bar/buzz1
> 2. $ mkdir -p bar/buzz2
> 3. $ mv --force bar foo/
> 
> Expected result: "bar" is merged into the other "bar"
> Actual result: error "mv: cannot move 'bar' to 'foo/bar': Directory not 
> empty"

This is the Linux kernel refusing to move (using the rename(2) syscall)
source to a non-empty directory:

Using 'strace' we can see the sys-call failure:

    rename("bar", "foo/bar")  = -1 ENOTEMPTY (Directory not empty)

In the kernel's rename(2) syscall manual page, the error is explained:
  ENOTEMPTY or EEXIST
    newpath is a nonempty directory, that is, contains entries
    other than "." and "..".
http://man7.org/linux/man-pages/man2/rename.2.html#ERRORS

mv(1) simply forwards the kernel error to the user.

> So I'm removing this dir, and trying to continue `mv`ing, and here we 
> coming to the bug I'm reporting.
> 
> Of course I could just copy, but `mv`ing is α) much faster, and β) 
> leaves dates of file creation in places, so I don't need to rebuild the 
> whole thing over again, only the files I gonna change.

"cp" will copy all files from inside "bar" to "foo/bar".
"mv" tries to replace "foo/bar" with "bar",
and because "foo/bar" is not empty, the kernel refuses to replace it.

If you care about preserving the fiels inside "bar/", but not the "bar"
directory itself, you can use:

    mv bar/* foo/bar/

Or you can just delete the "foo/bar" directory
(using -f ensures it will not complain if the directory doesn't exist):

   rm -rf ./foo/bar ; mv bar foo

As such, I'm closing this bug.
Discussion can continue by replying to this thread.

-assaf





Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 30 Oct 2018 02:02:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 29205 <at> debbugs.gnu.org and Konstantin Kharlamov <hi-angel <at> yandex.ru> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 30 Oct 2018 02:02:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 27 Nov 2018 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 145 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.