PhrozenByte/rmtrash

no use on Mac OS(catalina 10.15.6 (19G2021))

linking123 opened this issue ยท 14 comments

use sudo rmtrash test.md, wait long time, then get message like below:

/usr/local/bin/rmtrash: fork: Resource temporarily unavailable
rmtrash: cannot remove 'fiIdrRv': No such file or directory
/usr/local/bin/rmtrash: fork: Resource temporarily unavailable

/usr/local/bin/rmtrash: fork: Resource temporarily unavailable
basename: illegal option -- l
usage: basename string [suffix]
       basename [-a] [-s suffix] string [...]
rmtrash: cannot remove '-l': No such file or directory
/usr/local/bin/rmtrash: fork: Resource temporarily unavailable

but trash-cli: trash-put xxx is useful.

Hmm, weird. This kinda looks like #7, but for some reason there's no initial command failing causing this. Are you using the latest version of rmtrash? Run rmtrash --version, the latest version is v1.13.

According to Google the "fork: Resource temporarily unavailable" error is a known issue with OS X having a very low limit of concurrent processes running. But honestly I don't think that this is the issue, but rather some other command failing before, just like with #7 ๐Ÿ˜•

Unfortunately I don't have a OS X system, so I can't test it myself and can only hint you in some directions. You could enable bash's trace feature, so that bash prints all commands it executes. You can do so by running it with bash -x, like sudo bash -x /usr/local/bin/rmtrash test.md, and paste the output here. However, I can't promise to have time to look into it in the near future ๐Ÿ˜’

I have run sudo bash -x /usr/local/bin/rmtrash test.md , get output msg:

+ LC_ALL=C
++ basename /usr/local/bin/rmtrash
+ APP_NAME=rmtrash
+ VERSION=1.13
+ BUILD=20190331
++ which rm
+ RM_CMD=/bin/rm
+ '[' -z /bin/rm ']'
+ '[' '!' -x /bin/rm ']'
++ which trash-put
+ TRASH_CMD=/Library/Frameworks/Python.framework/Versions/3.7/bin/trash-put
+ '[' -z /Library/Frameworks/Python.framework/Versions/3.7/bin/trash-put ']'
+ '[' -z /Library/Frameworks/Python.framework/Versions/3.7/bin/trash-put ']'
+ '[' '!' -x /Library/Frameworks/Python.framework/Versions/3.7/bin/trash-put ']'
+ SHELL_IN_INTERACTIVE_MODE=false
+ tty -s
+ '[' 0 -eq 0 ']'
+ SHELL_IN_INTERACTIVE_MODE=true
++ getopt -n rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.md
+ OPTIONS=' -- rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.md'
+ eval set -- ' -- rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.md'
++ set -- -- rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.md
+ FORCE=false
+ INTERACTIVE=default
+ ONE_FILE_SYSTEM=false
+ PRESERVE_ROOT=true
+ RMDIR_MODE=false
+ RECURSIVE=false
+ VERBOSE=false
+ FORBID_ROOT=never
+ true
+ case "$1" in
+ shift
+ break
+ '[' 29 -eq 0 ']'
+ '[' never '!=' never ']'
+ '[' true == false ']'
+ '[' default == once ']'
+ EXIT=0
+ '[' 29 -gt 1 ']'
++ getOptionsAsCmdString /usr/local/bin/rmtrash
++ local CMD=/usr/local/bin/rmtrash
++ '[' false == true ']'
++ '[' default '!=' default ']'
++ '[' false == true ']'
++ '[' true == false ']'
++ '[' false == true ']'
++ '[' false == true ']'
++ echo /usr/local/bin/rmtrash
+ CMD=/usr/local/bin/rmtrash
+ '[' 29 -gt 1 ']'
+ eval '/usr/local/bin/rmtrash "$1"'
++ /usr/local/bin/rmtrash rmtrash
/usr/local/bin/rmtrash: fork: Resource temporarily unavailable
...
rmtrash: cannot remove 'rmtrash': No such file or directory
...
basename: illegal option -- o
usage: basename string [suffix]
       basename [-a] [-s suffix] string [...]
rmtrash: cannot remove '-o': No such file or directory
/usr/local/bin/rmtrash: fork: Resource temporarily unavailable

Hmmm... Not sure whether this is actually the issue, but it looks like your getopt isn't compatible with GNU's getopt. Please try again after installing gnu-getopt using brew.

Closing this for now due to inactivity. Please don't hesitate to re-open it if this wasn't the issue.

Hmmm... Not sure whether this is actually the issue, but it looks like your getopt isn't compatible with GNU's getopt. Please try again after installing gnu-getopt using brew.

Yes. After some debugging, I get the solution: install gnu-getopt. Besides, stat from coreutils is also required on macOS for stat -c.

Thanks @laggardkernel, I've updated the README.md accordingly just now ๐Ÿ‘

Hi, I'm on macOS Monterey 12.3 and getting the same problem whenever trying to use any rmtrash command, I tried rmtrash --help and rmtrash --version. Both resulted in the /usr/local/bin/rmtrash: fork: Resource temporarily unavailable loop. I tried running brew reinstall gnu-getopt and have already installed coreutils. Any idea how to fix this?
thanks

@hugofluhr Please do the same as described in #14 (comment), let's see whether bash -x gives us some hints about what is going wrong.

gnu-getopt and gstat @hugofluhr

GNU getopt seems to be backward compatible with BSD getopt. But it's not the case for gstat, you don't wanna link gstat as stat.

I am having the same issues as @hugofluhr on macOS. I'm running macOS Ventura 13.1 (22C65) on intel. I've installed both coreutils (9.1) and gnu-getopt (2.38.1) via homebrew. I've installed trash-cli in two different ways with no difference in outcome (via homebrew and via conda). Running the bash -x command as suggested by @PhrozenByte retrieves the same output, but I've posted it in full just in case there is a difference I missed.

+ LC_ALL=C
++ basename /usr/local/bin/rmtrash
+ APP_NAME=rmtrash
+ VERSION=1.14
+ BUILD=20201127
++ which rm
+ RM_CMD=/bin/rm
+ '[' -z /bin/rm ']'
+ '[' '!' -x /bin/rm ']'
++ which trash-put
+ TRASH_CMD=/Users/rehviding/miniconda3/envs/test/bin/trash-put
+ '[' -z /Users/rehviding/miniconda3/envs/test/bin/trash-put ']'
+ '[' -z /Users/rehviding/miniconda3/envs/test/bin/trash-put ']'
+ '[' '!' -x /Users/rehviding/miniconda3/envs/test/bin/trash-put ']'
+ SHELL_IN_INTERACTIVE_MODE=false
+ tty -s
+ '[' 0 -eq 0 ']'
+ SHELL_IN_INTERACTIVE_MODE=true
++ getopt -n rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.txt
+ OPTIONS=' -- rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.txt'
+ eval set -- ' -- rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.txt'
++ set -- -- rmtrash -o fiIdrRv -l force -l interactive:: -l one-file-system -l no-preserve-root -l preserve-root -l dir -l recursive -l verbose -l forbid-root:: -l forbid-root-force -l help -l version -- test.txt
+ FORCE=false
+ INTERACTIVE=default
+ ONE_FILE_SYSTEM=false
+ PRESERVE_ROOT=true
+ RMDIR_MODE=false
+ RECURSIVE=false
+ VERBOSE=false
+ FORBID_ROOT=never
+ true
+ case "$1" in
+ shift
+ break
+ '[' 29 -eq 0 ']'
+ '[' never '!=' never ']'
+ '[' true == false ']'
+ '[' default == once ']'
+ EXIT=0
+ '[' 29 -gt 1 ']'
++ getOptionsAsCmdString /usr/local/bin/rmtrash
++ local CMD=/usr/local/bin/rmtrash
++ '[' false == true ']'
++ '[' default '!=' default ']'
++ '[' false == true ']'
++ '[' true == false ']'
++ '[' false == true ']'
++ '[' false == true ']'
++ echo /usr/local/bin/rmtrash
+ CMD=/usr/local/bin/rmtrash
+ '[' 29 -gt 1 ']'
+ eval '/usr/local/bin/rmtrash "$1"'
++ /usr/local/bin/rmtrash rmtrash

It then loops over:

/usr/local/bin/rmtrash: fork: Resource temporarily unavailable

With the occasional:

rmtrash: cannot remove 'rmtrash': No such file or directory

and:

basename: illegal option -- o
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
rmtrash: cannot remove '-o': No such file or directory

Since I don't own any OS X devices, I unfortunately can't really debug this issue... I presume that some people got it working. Did you try installing gstat as well (not sure whether this is a package, or just a script)? If yes, we should add it to the requirements list. If we need any changes in the script, I'm happy to include them, too. Maybe someone can tell whether and how they got it working? @linking123 @laggardkernel @hugofluhr

I do have gstat, which appears to be a script. I've tried changing line 724 in trashrm to use gstat instead of stat but I get no difference in behaviour. I'll keep trying to debug this issue and keep updated if I find any clues that maybe some of the macOS users can help solve.

I managed to track it down, you were right about getopt being inconsistent between macOS and Linux. I installed gnu-getopt but needed to set it higher in the path:
export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"