ALL my AppleScripts stopped working

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

Moderator: Mr_Noodle

ALL my AppleScripts stopped working Mon Feb 12, 2024 6:41 am • by Lachlan Williams
OK, so I have a number of different Hazel rules, all of which have been working fine. Each of these rules does a bunch of things based on content within PDF files (including using a lookup table), including:
1. Renamine the file
2. Adding tags
3. Moving the file to a defined path (from the lookup table)
4. Sorting into subfolders
5. Creating a text file using an AppleScript file (calling it from Hazel with parms passed in)

Step 5 is always the last action in my Hazel rule (I've had issues before with AppleScript not working), so that if the AppleScript fails, it doesn't stop the other steps running.

Steps 1-4 continue to work fine as they always have. Step 5 fails with an error (from Hazel).

This was all working OK until a few weeks ago - instinctively, I feel like this might be a "permissions" issue within Mac OS, but not sure. Maybe it's a Mac OS update has changed something (not sure if I've updated Hazel recently - on v5.3.1). Any ideas?
Lachlan Williams
 
Posts: 13
Joined: Fri Jun 11, 2021 4:06 am

Re: ALL my AppleScripts stopped working Mon Feb 12, 2024 10:31 am • by Mr_Noodle
First off, I suggest updating to 5.3.2 though not sure if it affects your issue. For that, follow the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/

Report back with the results.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

OK, I found and fixed the problem, but along the way I discovered what might be some sort of caching bug which I thought I'd share in case it helps.

Before I start that explanation I will also share that no matter what I tried, I could not update to version 5.3.2 as you suggested. It simply wouldn't recognise that a newer version than 5.3.1 was available...but that did happen recently (some weeks later) without me doing anything and so now I'm on version 5.3.2. Importantly, the "caching bug" that I'm about to describe to you occured with version 5.3.2.

So...let's get the embarrassing part out of the way. The error was occurring because all the AppleScripts I use were all trying to write small text files to a "sandbox" folder used by Excel for Mac and somewhere along the way, Microsoft decided to change the folder path slightly in one of the Excel version updates. I use VBA to do "Stuff" with those files...
https://macexcel.com/examples/setupinfo/sandbox/

Previous path was:
"/Users/[username]/Library/Group Containers/UBF8T346G9.Office/Excel/"

New path is:
"/Users/[username]/Library/Group Containers/UBF8T346G9.Office/Excel Library/"

(facepalm) Thanks, Microsoft! :cry:

So...easy fix...I changed ALL those AppeScripts to point to the updated "Excel Library" directory path! (If I was smart enough, I'd know how to make all the AppleScripts point to a central "Global" variable somewhere, but I don't know how to do that, so each and every one of the script files has that folder path embedded in the script code (there are 2 reasons I'm telling you this, only 1 of which is hoping you'll tell me the secret to doing the global variable thing... :D ). Never mind, I'll ask ChatGPT. :D

So, the scripts all started working again when the Hazel rules matched! YAY! :) Except for 2 scripts...both were being called by the same Hazel rule (it calls 2 scripts in succession under actions when the rule matches). Argh! Why doesn't it work?! I was CERTAIN that I had updated every one of those script files with the updated Excel Library folder path...and...as it turns out...I had! So, I started debugging. I eventually worked out how to view the logs in the Console (wish I'd known before...it would have led me to the first issue much quicker!) and I found this:

2024-03-18 21:51:09.943 hazelworker[55498] OSAScript error: {
NSLocalizedDescription = "sh: /Users/lachlan/Library/Group Containers/UBF8T346G9.Office/Excel/Macro Tickets/55 Bradbury-20240318-215109.txt: No such file or directory";
NSLocalizedFailureReason = "sh: /Users/lachlan/Library/Group Containers/UBF8T346G9.Office/Excel/Macro Tickets/55 Bradbury-20240318-215109.txt: No such file or directory";

It's still pointing to the OLD folder path...so, I took the following troubleshooting steps:

1. Double-check that scripts are correct (they were)
2. Edit the rule actions which call those AppleScripts by removing and then re-adding all the imported attributes (didn't solve)
3. Update file timestamp on the relevant AppleScript files by re-saving them (didn't solve)
4. Remove the actions from the Hazel rule which call the scripts and re-add those actions from scratch (didn't solve)
5. As above but saved the Hazel Rule after removing the actions and before re-adding them (didn't solve)
6. As above but QUIT Hazel after removing the actions (and saving the rule) before re-adding them (SOLVED!)

Seems like a maybe caching issue to me, but will leave you to ponder...
Lachlan Williams
 
Posts: 13
Joined: Fri Jun 11, 2021 4:06 am

Re: ALL my AppleScripts stopped working Mon Mar 18, 2024 8:36 am • by Mr_Noodle
Thanks for the update. I'm wondering if Hazel was already running rules for that folder and was never exiting (could happen because of a loop or some very resource-intensive/long running actions.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron