GNU bug report logs - #47960
28.0.50; delete-by-moving-to-trash fails on directories?

Previous Next

Package: emacs;

Reported by: Protesilaos Stavrou <info <at> protesilaos.com>

Date: Thu, 22 Apr 2021 20:49:01 UTC

Severity: normal

Tags: fixed, patch

Merged with 48280

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 47960 in the body.
You can then email your comments to 47960 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-gnu-emacs <at> gnu.org:
bug#47960; Package emacs. (Thu, 22 Apr 2021 20:49:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Protesilaos Stavrou <info <at> protesilaos.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 22 Apr 2021 20:49:01 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; delete-by-moving-to-trash fails on directories?
Date: Thu, 22 Apr 2021 23:48:16 +0300
On trunk the (setq delete-by-moving-to-trash t) no longer works in Dired
and Eshell when trying to delete a directory.

Steps to reproduce with emacs -Q:

+ Evaluate (setq delete-by-moving-to-trash t).
+ Use 'C-x C-j' to jump to a dired buffer.
+ Then type '+' and create a new directory named "test" or whatever.
+ With point over the newly created directory ,type "D", and confirm.

You get an error: "file-error: Renaming: Not a directory [...]"

Same if you try to delete the directory with the 'rm -r' command from
inside eshell (though 'rmdir' works in this case).

For completeness, M-x shell works with either 'rm -r' and 'rmdir'.

-- 
Protesilaos Stavrou
https://protesilaos.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47960; Package emacs. (Thu, 22 Apr 2021 21:12:01 GMT) Full text and rfc822 format available.

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

From: Gregory Heytings <gregory <at> heytings.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: 47960 <at> debbugs.gnu.org
Subject: Re: bug#47960: 28.0.50; delete-by-moving-to-trash fails on
 directories?
Date: Thu, 22 Apr 2021 21:11:19 +0000
>
> On trunk the (setq delete-by-moving-to-trash t) no longer works in Dired 
> and Eshell when trying to delete a directory.
>
> Steps to reproduce with emacs -Q:
>
> + Evaluate (setq delete-by-moving-to-trash t).
> + Use 'C-x C-j' to jump to a dired buffer.
> + Then type '+' and create a new directory named "test" or whatever.
> + With point over the newly created directory ,type "D", and confirm.
>
> You get an error: "file-error: Renaming: Not a directory [...]"
>
> Same if you try to delete the directory with the 'rm -r' command from 
> inside eshell (though 'rmdir' works in this case).
>
> For completeness, M-x shell works with either 'rm -r' and 'rmdir'.
>

Are you sure this bug is not due to something going wrong on your machine? 
I'm unable to reproduce this bug here, both Dired and Eshell seem to work 
as expected.

Did you by any chance define a 'system-move-file-to-trash' function?

Does it work when you (setq trash-directory <something>)?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47960; Package emacs. (Thu, 22 Apr 2021 21:43:02 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: 47960 <at> debbugs.gnu.org
Subject: Re: bug#47960: 28.0.50; delete-by-moving-to-trash fails on
 directories?
Date: Fri, 23 Apr 2021 00:42:00 +0300
On 2021-04-22, 21:11 +0000, Gregory Heytings <gregory <at> heytings.org> wrote:

>>
>> On trunk the (setq delete-by-moving-to-trash t) no longer works in
>> Dired and Eshell when trying to delete a directory.
>>
>> Steps to reproduce with emacs -Q:
>>
>> + Evaluate (setq delete-by-moving-to-trash t).
>> + Use 'C-x C-j' to jump to a dired buffer.
>> + Then type '+' and create a new directory named "test" or whatever.
>> + With point over the newly created directory ,type "D", and confirm.
>>
>> You get an error: "file-error: Renaming: Not a directory [...]"
>>
>> Same if you try to delete the directory with the 'rm -r' command from
>> inside eshell (though 'rmdir' works in this case).
>>
>> For completeness, M-x shell works with either 'rm -r' and 'rmdir'.
>>
>
> Are you sure this bug is not due to something going wrong on your
> machine? I'm unable to reproduce this bug here, both Dired and Eshell
> seem to work as expected.

It could be, though I have only updated Emacs in the last ~10 days.

What seems to be the issue is when a deleted entry of the same name
already exists.  I emptied my trash and tried the above recipe: the
problem would not occur.  But upon immediate retry the problem appeared,
presumably because "test" already existed in the trash.

> Did you by any chance define a 'system-move-file-to-trash' function?

No

> Does it work when you (setq trash-directory <something>)?

Yes, it does.  Both for my original recipe and with the other case I
mentioned above.

I have always set this to nil, which makes it use the trash of
freedesktop.org.

-- 
Protesilaos Stavrou
https://protesilaos.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47960; Package emacs. (Fri, 23 Apr 2021 20:40:02 GMT) Full text and rfc822 format available.

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

From: Gregory Heytings <gregory <at> heytings.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 47960 <at> debbugs.gnu.org
Subject: Re: bug#47960: 28.0.50; delete-by-moving-to-trash fails on
 directories?
Date: Fri, 23 Apr 2021 20:39:20 +0000
[Message part 1 (text/plain, inline)]
>
> What seems to be the issue is when a deleted entry of the same name 
> already exists.  I emptied my trash and tried the above recipe: the 
> problem would not occur.  But upon immediate retry the problem appeared, 
> presumably because "test" already existed in the trash.
>

Indeed, this path of the code was recently changed (commit a5197e2240), 
and indeed, when a directory with the same name is trashed twice, it 
fails.  Patch attached.

(It can't be applied yet, I'm still waiting for the end of my paperwork.)
[Fix-bug-when-moving-directories-to-trash.patch (text/x-diff, attachment)]

Added tag(s) patch. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sun, 25 Apr 2021 11:03:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47960; Package emacs. (Fri, 07 May 2021 20:42:01 GMT) Full text and rfc822 format available.

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

From: Gregory Heytings <gregory <at> heytings.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 47960 <at> debbugs.gnu.org
Subject: Re: bug#47960: 28.0.50; delete-by-moving-to-trash fails on
 directories?
Date: Fri, 07 May 2021 20:41:38 +0000
A shorter (and therefore better) patch to solve this issue has been 
proposed in bug#48280.  It should be applied instead of this one.




Forcibly Merged 47960 48280. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 08 May 2021 11:45:03 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 24 May 2021 22:24:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 48280 <at> debbugs.gnu.org and Codruț Constantin Gușoi <mail <at> codrut.pro> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 24 May 2021 22:24:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47960; Package emacs. (Mon, 24 May 2021 22:27:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Protesilaos Stavrou <info <at> protesilaos.com>, 47960 <at> debbugs.gnu.org
Subject: Re: bug#47960: 28.0.50; delete-by-moving-to-trash fails on
 directories?
Date: Tue, 25 May 2021 00:26:11 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

> A shorter (and therefore better) patch to solve this issue has been
> proposed in bug#48280.  It should be applied instead of this one.

Your version of the patch looked more obviously (well, somewhat) correct
to me -- since it didn't change when the directory was created, if I
read the two patches correctly.  (Which may be important if there's a
race condition.)

And since the copyright clerk just said that your copyright assignment
is complete, I've now applied and pushed your patch to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 47960 <at> debbugs.gnu.org and Protesilaos Stavrou <info <at> protesilaos.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 24 May 2021 22:27: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, 22 Jun 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 302 days ago.

Previous Next


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