"The Application Can't Be Opened"

Yes. It is likely some hidden security permission (perhaps one that you auto-OKed when first asked and which the system is now not asking again).

I'm afraid I don't know what it could be.

When I did it the first time on my Sonoma Mac it said “Keyboard Maestro was prevented from modifying other application files”, which typically means that some file in the Library (usually Application Support) folder was accessed. Since Keyboard Maestro was not touching any specific file, and was simply running an AppleScript via osascript it's not at all clear what the system was complaining about.

You could try granting Full Disk Access permissions to the Keyboard Maestro Engine I suppose. Other than that, I would try looking through all the security permissions and ensuring Keyboard Maestro Engine is enabled for each of them (or, sigh, at least appears to be enabled).

1 Like

You can reset the entire permissions system in Terminal, which is sort of like getting rid of an itchy bug bite by cutting off your warm: It's drastic, but it usually works :). First quit all apps, then in Terminal, run this command:

tccutil reset Accessibility

Reboot, and you'll have a fresh start with the permissions system.

Warning: You will spend the next 157 hours clicking "OK" buttons, as every app you use that does anything even remotely useful will have to re-ask you for permission. But it's oftentimes the only way to clear out subtle issues like this one.

-rob.

3 Likes

… if the issue is with the Accessibility system and not one of the many other security systems.

1 Like

True, though this would at least eliminate the relatively-far-reaching Accessibility system as a suspect.

-rob.

1 Like

I've done reinstall (including clearing all settings, caches, etc.) and reset Accessibility permissions on two machines and sadly it did not fix the problem in either case.

FWIW, for me the issue started after upgrading to 14.3. I use scripts to open files nearly daily in my work and did not have any problems on 14.2 (I don't remember at this point if I went 14.2→14.2.1→14.3 or straight to 14.3).

1 Like

Have you tried resetting the Launch Services cache?

I haven't tried that. How do you reset the Launch Services cache? (I'm running Sonoma 14.3)

The commands are here:

https://discussions.apple.com/thread/251735453

Note that I don't know whether this will work in Sonoma, or even whether it is a good idea.

But since the issue is related to opening files in applications, the Launch Services cache might be involved, and it's been known to cause other problems over the years.

I too have this exact problem ever since macOS 14.3. Resetting the Launch Services cache did not fix it.

Resetting Launch Services also didn't work for me.

I have a report from a user with this problem that reinstalling the target application (removing it, rebooting, and then installing it), resolved the problem.

So that might be worth trying.

Here are a few more observations (and a workaround):

One factor seems to be the presence or absence of the quarantine bit:

  • When I checked a few files for which "Open Finder selection with: BBEdit" resulted in "-128" errors, they all had the quarantine bit set.
  • (FYI: If xattr -p com.apple.quarantine /path/to/file produces any output other than "No such xattr: com.apple.quarantine", the quarantine bit is set for that file.)
  • After I removed the quarantine bit using xattr -d com.apple.quarantine /path/to/file, the file worked normally again with the "Open Finder selection with: BBEdit" action.

The AppleScript @mrpasini posted above seemed to behave identically to the "Open Finder selection with: BBEdit" action, but only when executed via Keyboard Maestro. When I ran the script via Script Debugger or Script Editor, it worked fine on all files regardless of the presence of the quarantine bit.

Alfred's "Open with..." command also worked fine with all files.

If I use Keyboard Maestro's "Execute Shell Script" action with open -a "BBEdit" /path/to/file, the issue does not seem to be present. So as a workaround, I have now replaced my "Open Finder selection with: BBEdit" action with:

(Sonoma 14.3.1, Keyboard Maestro 11.0.2)

4 Likes

Just in case you weren't aware, you can install the BBEdit Command Line Tools (in the BBEdit menu in the app). Then you could just use the shell script bbedit "$KMVAR_Local_selectedFile".

No functional difference, but might be a thousandths of a hundredths of a nanosecond quicker :).

-rob.

Heh, that's true, @griffman. I actually do use bbdiff extensively myself. Since I have similar macros for other apps, too, I went for a universal approach, so they are all the same.

2 Likes

This issue has just kind of disappeared for me. I didn't take any troubleshooting steps. :man_shrugging:

@Jack_Brannen, is is possible that you were only using the KM macro recently with files that didn't have the quarantine bit set (see my post above)? Because on both of my Macs, the issue is still reliably reproducible.

@NSSynapse Well, I spoke too soon. The issue is still occurring for me, but it's sporadic.

I just tested a file that worked, and the quarantine bit was not set—as you suspected. I'll test it again next time I find a file that doesn't work.

@NSSynapse It failed again, I checked, and the quarantine bit WAS set.

@peternlewis Is this something you may find a workaround for? Does the quarantine bit give you insight to change some code? Or is this a macOS limitation?

I too have had various scripts & automations fail in the latest Sonoma. Make sure to look in a few places to enable things under Privacy & Security - try "Accessibility", and "Automation", and also "Input Monitoring"

this apple security system is a disaster. the completely opaque interface, "xattr" nonsense, mess of a control panel, & especially the inane system where you get "one shot" to approve something...
/rant