Open ghost opened 3 years ago
Try adding the calling script and/or the 'trash' binary to: System Preferences -> Security & Privacy -> Privacy -> Accessibility .
After 15 days I decided to just install another trash
binary and move on. Maybe someone else would like to test this and see if that is indeed what causes error -1701. It may be. It would be good if this binary was updated to mention the modern macOS security hurdles.
@jprokos agreed, I started using https://github.com/morgant/tools-osx/blob/master/src/trash, it's much better:
Delete using Finder
is the default (so Put back
still works). If Finder
fails, it quietly falls backs to non-finder delete so it works anyway.
IMHO the ali-rantakari/trash
should not be the one installed by brew install trash
Came here with this problem.
FWIW, I noticed the -1701
error appears only in Kitty.app
for me, but not in MacOS's built-in Terminal.app
.
Another observation is that when I have trash
aliased as rm
e.g. with alias rm="trash -v -F"
in my ~/.zshrc
, I get -1701
error when I do rm file-path
, but not when I do trash file-path
.
/usr/local/bin/{trash,zsh}
, Terminal.app
and Kitty.app
added in System Preferences -> Security & Privacy -> Privacy -> Accessibility.Thank you.
tccutil reset AppleEvents
Kitty.app
I ran the command above and then invoked trash <file>
, which presents the "Apple Events"
permission prompt, and everything seems to be working after approving the permission. Hope this helps!
I solved this for trash -F
by re-enabling Finder permissions under System Settings → Privacy & Security → Automation → iTerm (which I had manually disabled at some point).
I solved the problem with the help of @gsbabil and @veloxo comments. I share my solution steps.
In Sonoma 14.5, System Settings > Privacy & Security > Automation
must still contain the Finder control access permission for terminal app to execute trash -F
.
I use Tabby as a terminal app, but when I execute trash -F
, the permission request dialog does not appear.
It appears that Automation permission must be requested from the app and cannot be added from System Settings.
The following is how to request it manually.
# Reset Automation permission for the bundle ID of the app currently at the frontmost (i.e., terminal app) to ensure the appearance of the permission request dialog.
tccutil reset AppleEvents "$(osascript -e 'id of app (path to frontmost application as text)')"
# Use the Finder application to get the name of the item in the trash (this opens a permission request dialog).
osascript -e 'tell application "Finder" to get name of items in trash'
Finally, by allowing the request, I was able to successfully execute trash -F
.
I am getting this error when calling a command in a script. The same command called in a shell doesn't receive the error.
Shell script being called by another shell script with "$1" being a single quoted path.
Result:
Command line
This results in the files being sent to the trash