Apparently, all or some applications in OSX cach AppleScripts somewhere in the system. So far I have tried 3 applications that can trigger an AppleScript like the “Mail” app, “Task Till Dawn” and “Plisterine”. Once the triggering rule is in place, it works as expected but if the script is modified, the rule continues to run the old version of the script.
I’ve not beeing able to find an easy workaround. I’ve tried deleting and re-creating the rules, renaming the rules and renaming the script file, all with mixed results. It’s so frustrating that I had to implement a notification from the script showing a version number to keep me sane :mad: Any idea of how to solve this Applescript caching issue??
Model: iMac, mac Mini
AppleScript: Version 2.9 (191)
Browser: Safari 537.36
Operating System: Mac OS X (10.10)
Quitting the applications does not resolve the issue. In the case of “Plisterine” the application is not even running at the time the script is executed (Plisterine is a launch agent manager for Mac OS, a frontend for launchd)
Restarting the Mac is far from ideal since my script requires multiple edits while perfecting and debugging.
When I searched what is Plisterine I found its page in Mac App Store in which I read :
With Plisterine you can create launch agents that launch an application/script:¨
¢ At a specific time every day¨, weekday, or day of the month
¨¢ On an interval, such as every 10 seconds, or every hour¨
¢ When a change occurs in a folder or to a file
¨¢ When a new volume or disk is mounted¨¨
¨¢ At load or login¨
¢ When your application/script crashes (relaunch it)
So I understood - but I may be wrong - that you may use Plisterine to relaunch the application/script which behaves wrongly.
Although it may look like it, you’re not actually reading or writing to a file. Preferences are all handled by a daemon that keeps them in memory while the relevant process is running; the files are just a sort of backup, for when the power goes off or the process isn’t running. That’s why it’s important to use NSUserDefaults or the defaults command-line tool.
I assumed that Plisterine is using some daemon to rule what it activate.
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) lundi 23 janvier 2017 16:42:24
That is the “keep alive” feature that reopens an app or script if it crashes or even if closed by the user. I use it, for example, to keep my Plex server alive but unfortunately, I don’t see how it could help with the AppleScript caching issue.
That is correct, and I “Unload” and “Load” my launch agents through terminal every time I make changes, this step is required and I also repeated those steps many times over while trying to resolve the issue. However, even if I’m not managing the launch agents correctly, the fact remains that even a native application like Apple Mail is doing the same “script caching” on simple rules like “when receiving an email with subject X, launch script Y”, renaming the rule or the script, deleting and creating a new one, etc. will not fix the issue 90% of the time.