Applescript / Scripting Bridge not working

Description of the issue:

Applescript / Scripting Bridge seems not to work.

I think I’m having a MacOS entitlements issue, but I might like to document the solution here.

My applescripts work in ScriptEditor, but no longer work from the command-line. iTerm 2 (signed application), (running bash,) invoking osascript.

I’m using the current release version,
Version 1.44.112 Chromium: 106.0.5249.119 (Official Build) (x86_64) but I may have noticed this issue on another recent build in the last week or two.

Steps to Reproduce (add as many as necessary):

Scripts that I use to extract a list of open URLs in tabs, grouped by window, now error with

A minimal example: osascript -l JavaScript -e 'Application("Brave").windows()'
No-op success: osascript -l JavaScript -e 'Application("Brave")'

My full example:

$ tabs-brave

/Users/mcint/Documents/tabs/brave/tabs.2022-10-20T14:43:21..log ... /Users/mcint/.iclouds/com~apple~ScriptEditor2/Documents/Tabs-Brave.scpt: execution error: Brave Browser got an error: Application isn’t running. (-600)

Actual Result (gifs and screenshots are welcome!):

[applescript] execution error: Brave Browser got an error: Application isn’t running. (-600)

Expected result:

I get a full list of URLs and titles, from tabs, from windows of Brave Browser using Applescript.

Reproduces how often:

Consistent, every time.
In osascript invocation from command-line.
In Script Editor, exported to text

Operating System and Brave Version(See the About Brave page in the main menu):

  • macOS 12.6 (21G115)
  • Brave Version 1.44.112 Chromium: 106.0.5249.119 (Official Build) (x86_64)

Additional Information:

My scripts

    args="$*"; # OneTab format
    _file=~/Documents/tabs/brave/tabs.$(date +%FT%T)."${args// /-}".log;
    echo -n "$_file ... ";
    _count=$(osascript ~/.iclouds/com~apple~ScriptEditor2/Documents/Tabs-Brave.scpt | tee -a "$_file" | grep -ve '^#' -e '^$' | wc -l;);
    echo "$_count"

-- use AppleScript to export tabs from chromium... or any? native browser on macOS

-- output tabs in format compatible with OneTab
-- faster, low-touch (but macOS-only) way of exporting tabs

set nl to linefeed
set cntT to 0
set cntW to 0
set out to "# tabs-brave. OneTab format." & nl
tell application "Brave Browser"
	set wts to properties of tabs of windows
	repeat with w in wts
		repeat with t in w
			set out to out & nl & URL of t & " | " & title of t
			set cntT to 1 + cntT
		end repeat
		set out to out & nl
		set cntW to 1 + cntW
	end repeat
end tell
set out to out & "# end w:" & cntW & ", t:" & cntT & nl

Issue is unrelated to Brave.

It was resolved by creating a new tmux session, ensuring a new tmux server instance started, from within a new version of iTerm.

The issue relates to macOS tracking of processes allowed to “use system entitlements” and make use of macOS Security & Privacy permissions.

Security sometimes requires devolving from a system that works. macOS, undoing the successes of unix. the new propriety.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.