Subject: bug#47960: 28.0.50; delete-by-moving-to-trash fails on directories?

From: Protesilaos Stavrou <[email-masked]>
Date: Fri, 23 Apr 2021 00:42:00 +0300

On 2021-04-22, 21:11 +0000, Gregory Heytings <[email-masked]> 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