"The Application Can't Be Opened"

I have a bunch of macros just like this one for opening files in the Finder with specific applications.

Just recently these have all started to fail with an error message like this one (screenshot below). Actually TWO of these error messages pop up every time.

I've tried going back to the macro and re-selecting the Numbers app (e.g.) again to make sure KM is seeing the app correctly. It is.

Anyone got any ideas?

Open With - Numbers.kmmacros (18 KB)

1 Like

@Jack_Brannen,

I tried this about a month ago and received the same error(s). I forgot about it and didn't chime in to the forum. Maybe @peternlewis can shed some light.

When I try this I get the error you mentioned, but also get a notification that says
"KBM was prevented from modifying apps on your Mac."
Looks like a permission thing.

I added KBM to App Management in the Security panel, but no change. Maybe the engine needs to be added but I don't know how to do that.

Same problem here: Open Finder Selection in BBEdit 15.

My workaround is to use the shell to open the app.

1 Like

Might need Automation control over the target application perhaps?

Enabled here but still get the error trying to open text files in BBEdit whose default app is not BBEdit.

1 Like

The apps (TextEdit, Pages and Safari) that I tried were already added, to the Automation area, and throw the same error.

The action is a basic AppleScript that does:

set f to POSIX file "/Applications/Numbers.app" -- or whatever the path to the target application is
tell application "Finder" to open (the selection as alias list) using application file f

Try that using the Execute an AppleScript action, ensuring that it includes errors and does not abort the macro (both in the gear menu) and displays the results in a window and see what happens.

Yes, this works to open files with a different default app in BBEdit, but it fails with the -128 error if the default app is BBEdit:

tell application "Finder"
	set sel to selection
	if sel is not {} then
		set filepath to item 1 of sel as text --> The path to the one selected item.
		open filepath using application file id "com.barebones.BBEdit"
	end if
end tell

That is very weird. It looks like it is some sort of Apple bug, perhaps in the Finder?

When did it start?

Two things changed on my system. Ventura 136.4 (from 13.6.3), a security update. And BBEdit 15 replacing v14

I can't duplicate the behavior on Monterey 12.7.3 with BBEdit 14. Nor can I duplicate it on Monterey 12.7.2 with BBEdit 15.

1 Like

It does not appear to be restricted to just BBEdit, but I don't know what the cause is, or why is applies in only certain cases.

When Keyboard Maestro executes the AppleScript for this action, I have seen the system report something like “Keyboard Maestro was prevented from modifying out application files” os some such nonsense, so I wonder if the Finder or the AppleScript system is touching some file and that is resulting in a -128 “user canceled” error.

Does the AppleScript fail in the same way if run from Script Editor, and/or from osascript?

Run from Script Debugger on Ventura, the AppleScript can open .php, .htm and .txt documents all without the error.

I'm back on macOS 10.14 (Mojave) and I only recently moved from Keyboard Maestro v10 to v11. The macros I have like Jack_Brannen showed in the original post continued to work after upgrading KM, further suggesting it's a Ventura issue.

1 Like

I have the issue and I’m on Sonoma. I didn’t really use that feature though.

KC

I'm also on Sonoma and also have this issue.

1 Like

I have a Keyboard Maestro macro that feeds a selected file in the Finder to an app (an image to a Retrobatch applet). It broke recently with this -128 error, but I wasn't able to figure out why and fix it (reselecting the applet made no difference). And then it started working again. I dimly remember that there was some sort of extra dialog the first time it worked again, but I was moving fast and not paying attention. Not very useful, but a data point that it happened and stopped happening.

2 Likes

It occurs to me that if this is a security issue, then reinstalling the Keyboard Maestro application might result in the system re-prompting for whatever the hell it is missing.

  • Quit Keyboard Maestro and Keyboard Maestro Engine
  • For bonus points, trash the Keyboard Maestro.app, empty the trash, and restart.
  • Download a fresh copy from: https://download.keyboardmaestro.com/
  • If the file is still a .zip file, unzip it.
  • Use the Finder to move the resulting Keyboard Maestro.app application to the Applications folder (replacing the old version if you skipped step 2)
  • Launch the Keyboard Maestro app from the Applications folder.

Try the action.

There is no good reason why this would solve the problem, but it might poke the system into re-asking the question it wants permission for.

1 Like

Thanks for the suggestion Peter. Performed the reinstall and my system gave the same error. It's just weird because it works fine on my other non-Sonoma systems.

1 Like