Error executing Shortcut via commandline

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Error executing Shortcut via commandline Fri Apr 25, 2025 7:47 pm • by vjl323
This workflow had been working for months every day until today when I did some updates. Sadly I did too many updates to know which is the issue. The 4 I did were macOS 14.7.5 [from 14.7.4], a new version of Safari 18.4, Hazel 6.0.4 [from 6.0.3 I believe],and Retrobatch Pro 2.2.2 [from 2.1.something].

The logs show that Hazel can not execute a Shortcut that it has been executing fine before:

2025-04-25 19:08:41.712 hazelworker[15601] Running worker (v6.0.4) for folder with identifier: 16777230-139635518.
2025-04-25 19:08:41.715 hazelworker[15601] ###Arch: arm64
2025-04-25 19:08:41.715 hazelworker[15601] ###main load address: 0x104db0000
2025-04-25 19:08:41.715 hazelworker[15601] ###Hazel Core load address: 0x1053c8000
2025-04-25 19:08:41.715 hazelworker[15601] ###Noodle load address: 0x1056c8000
2025-04-25 19:08:41.715 hazelworker[15601] ###CK load address: 0x1052b0000
2025-04-25 19:08:41.732 hazelworker[15601] Processing folder FOR EBAY (forced)
2025-04-25 19:08:43.901 hazelworker[15601] IMG_7896.jpg: Rule Remove EXIF matched.
2025-04-25 19:08:44.087 hazelworker[15601] Error executing Shortcut Remove Metadata: Error Domain=Hazel Code=9 "Error executing Shortcut via commandline." UserInfo={NSLocalizedDescription=Error executing Shortcut via commandline.}
2025-04-25 19:08:44.087 hazelworker[15601] [Error] Shortcut failed: Could not run Shorcut Remove Metadata: .
2025-04-25 19:08:44.089 hazelworker[15601] Done processing folder FOR EBAY

The issue is I may have blanked out one of the 2 fields in the Shortcut, but I have tried them both ways and get the same results.

I have screenshots. https://www.dropbox.com/scl/fi/mw2sdxq9j20skwb3uwdkh/Hazel-2025-04-25-19-18-56.png?rlkey=pep776sg7fi2mcbnuj1js49pj&dl=0

This is the Shortcut:

https://www.dropbox.com/scl/fi/zx2k7l4llm31wpcmv3t95/Remove-Metadata-2025-04-25-19-15-25.png?rlkey=qg88s2r9n4vropelhn2t5ex0o&dl=0

And this is the Retrobatch process that gets called by the Shortcut:

https://www.dropbox.com/scl/fi/66izaweukf3bhmg316g6u/Process-Product-Images.retrobatch-2025-04-25-19-19-29.png?rlkey=bgj4rym345x65lyzem7ee0xjp&dl=0

Note in the Shortcut the "Input Images" area - that is where I might have clicked off [I wish there was an easy way to retrieve past versions of Shortcuts via Time Machine!]. I have tried to change that to the FOR EBAY folder and the results are the same - error executing the shortcut from the commandline.

Also a spelling typo in the Logs - Shortcut failed: Could not run Shorcut Remove Metadata

[Shortcut is missing the "t"].

Unsure how to proceed. I process 100s of images a day using this workflow and now I'm stuck. How can I troubleshoot this further? Thanks for any help you can provide!
vjl323
 
Posts: 3
Joined: Fri Apr 25, 2025 7:09 pm

Are you able to run the Shortcut using the commandline in Terminal?
Mr_Noodle
Site Admin
 
Posts: 11948
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Error executing Shortcut via commandline Mon Apr 28, 2025 2:30 pm • by vjl323
I sent a support message after further research. There is a major bug in 14.7.5 that prevents /usr/bin/shortcuts from ever being run - even in Terminal. See details at: https://discussions.apple.com/thread/25 ... 1347439022

What I was able to do last night is remove the dependency on Shortcuts, since all it was doing was calling RetroBatch. Turns out RetroBatch has a command line that can be called via script, so using the embedded script feature of Hazel, I've been able to call RetroBatch directly.
vjl323
 
Posts: 3
Joined: Fri Apr 25, 2025 7:09 pm

Re: Error executing Shortcut via commandline Sun Jul 13, 2025 8:56 am • by damu_be
I confirm this issue/bug is still present with macOS 14.7.6 too.

Hazel isn't able to run Shortcuts natively because the command line version of Shortcuts is broken on Sonoma since 14.7.5.

In my case, the Shortcuts automation I need to run via Hazel are more complex than simply launching RetroBatch.

Therefore I was motivated to look for a workaround and I finally found one: AppleScript

Code: Select all
tell application "Shortcuts"
   run shortcut "name_of_your_shortcut" with input theFile
end tell


Just replace name_of_your_shortcut with the exact name AND keep the double quotes.

I've successfully implemented this workaround for the rules that broke down after the 14.7.5 update.

Hope this will help others who face the same issue!
damu_be
 
Posts: 3
Joined: Fri May 19, 2017 6:04 am

Re: Error executing Shortcut via commandline Sun Jul 13, 2025 9:18 am • by vjl323
Thank you for that! It is good to know there's a functioning workaround. I was also able to confirm that it is still broken in 14.7.6 - I reported it again but I'm not hopeful Apple will fix their mistake. So I'm glad AppleScript is able to call a Shortcut without the functioning command line version! Thank you, thank you, thank you! :)
vjl323
 
Posts: 3
Joined: Fri Apr 25, 2025 7:09 pm

Glad you figured it out. AppleScript was originally the "official" way to run Shortcuts but it didn't work when it first launched. Frankly, Shortcuts on the Mac has been horribly implemented and it's always a guessing game to figure out what works and what doesn't with each release. Nonetheless, I'll look into switching back to AppleScript internally.
Mr_Noodle
Site Admin
 
Posts: 11948
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support