"The Application Can't Be Opened"

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