I've read through everything I can find on this on the Forums, but I am still getting errors.
When developing, I have a folder I need to purge to eliminate cache stores.
From terminal, I run "sudo rm -r '/Users/path/to/folder/', it prompts me for my password and it works. The contents of the folder are purged.
Within an Alfred Workflow, I have tried 2 approaches.
1. Using Run Script (/usr/bin/osascript) I have tried:
do shell script "/bin/bash -c rm -r '/Users/path/to/folder/'" with administrator privileges
The osascript prompts me for for my password using TouchID which I successfully provide, but it produces this error:
: execution error: shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted usage: rm [-f | -i] [-dPRrvW] file ... unlink file (64)
1. Using Run NSAppleScript I have tried (based on suggestions from other posts on the Forum):
on alfred_script(q)
do shell script "/bin/bash -c rm -r '/Users/path/to/folder/'" with administrator privileges
end alfred_script
Alfred prompts me to type in my password which I successfully provide, but it produces this error:
NSAppleScriptErrorAppName = "Alfred 4";
NSAppleScriptErrorBriefMessage = "usage: rm [-f | -i] [-dPRrvW] file ... unlink file";
NSAppleScriptErrorMessage = "usage: rm [-f | -i] [-dPRrvW] file ... unlink file";
NSAppleScriptErrorNumber = 64;
NSAppleScriptErrorRange = "NSRange: {22, 173}";
It seems like it must be a permission error as I have used the above approach multiple times in other Alfred Workflows, but this is the first time I have needed sudo/admin authorization. My broader searches on the Internet regarding the shell-init issue seem to indicate the same.
My guess is I'm missing something super obvious, but I can't seem to figure it out.
Any help or guidance would be greatly appreciated. Thank you in advance for your time and consideration.