sindresorhus / trash-cli

Move files and folders to the trash
MIT License
1.33k stars 35 forks source link

windows-trash.exe does not work with subst virtual drive paths #38

Open Leftium opened 1 year ago

Leftium commented 1 year ago
P:\tmp>subst
       &REM Show subst virtual drive maping:
P:\: => V:\Insync\Dropbox\p

P:\tmp>windows-trash.exe FILE_TO_TRASH
       &REM Running from virtual drive silently fails to remove file:

P:\tmp>dir
06/18/2023  12:15 AM                 0 FILE_TO_TRASH
06/17/2023  11:10 PM            28,672 windows-trash.exe

P:\tmp>v:
       &REM Switch to non-virtual drive.

V:\Insync\Dropbox\p\tmp>windows-trash.exe FILE_TO_TRASH
                        &REM Running from non-virtual drive successfully to removes file:

V:\Insync\Dropbox\p\tmp>dir
06/17/2023  11:10 PM            28,672 windows-trash.exe

I was trying to debug or workaround this error:

/p/tmp
$ trash FILE_TO_TRASH
Error: Command failed: V:\pnpm-home\global\5\.pnpm\trash@6.1.1\node_modules\trash\lib\windows-trash.exe P:\tmp\FILE_TO_TRASH

    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5)

The error does not happen if not in a virtual drive:

/v/Insync/Dropbox/p/tmp
$ trash FILE_TO_TRASH

/v/Insync/Dropbox/p/tmp
$ ls
windows-trash.exe*

Also the error only occurs after trash-cli version 3.0.0. (So my workaround is to use version 2.0.0)

Environment: