Closed bug report

kicad_upgrade fails with NameError: name 'subprocess' is not defined (macOS, no KiCad installed)

Kyle Bergstedt · 1mo ago ·closed by John Lauer

adom/kicad-bridge 1.0.142 · adom/adom-bridge 2.1.129 · adom/adom-bridge-macos 1.9.209 · adom/core 4.14.0 · macOS (Apple silicon)

What I did

On a Mac with no KiCad installed, followed exactly the path the bridge's own hints prescribe. kicad_readiness and kicad_list_versions both return errorCode: "host_app_not_installed", and both _hints say:

KiCad not detected — offer to install it, then run kicad_upgrade '{}' (installs the official build from scratch: ... macOS: universal DMG into /Applications/KiCad, de-quarantined).

So I ran adom-bridge kicad_upgrade '{}'.

What I expected

KiCad 10.0.6 installed into /Applications, per the hint.

What happened

{
  "durationMs": 71363,
  "error": "Internal error: name 'subprocess' is not defined",
  "output": "",
  "status": "error",
  "success": false,
  "timeoutSeconds": 140
}

Reproduced twice, ~20 minutes apart, identical error. Second run durationMs: 80388.

The message is a Python NameError — a missing import subprocess in the kicad_upgrade handler (or in the macOS branch of it). The non-trivial durationMs (71 s and 80 s) suggests it gets as far as downloading or preparing before reaching the line that needs subprocess, so the failure is late rather than at entry.

Why this one stings

kicad_upgrade is the only route the bridge offers for this case on macOS:

  • It is what host_app_not_installed explicitly tells the agent to call, and the hint goes out of its way to say "DON'T make the user install it by hand" and "never hand the user a manual download".
  • desktop_install_kicad is Windows-only (winget wrapper), so there is no structured fallback verb on macOS.
  • That leaves shell_execute, which is approval-gated (see the separate note below).

Net effect: on a Mac with no KiCad, an agent following the documented path has no working way to install it, and the bridge's own guidance forbids the manual workaround.

Suggested fix

Add the missing import subprocess in the kicad_upgrade handler and add a smoke test that runs the verb on a runner without KiCad present — the bug is invisible on any box that already has KiCad, which is probably why it survived.

Two adjacent things noticed while working around this

Filing here rather than separately since they surfaced on the same path; happy to split them out or move them to adom/adom-bridge if that is the better home.

  1. shell_execute approval appears to expire at 60 s and report the expiry as a user deny. Three attempts returned stderr: "Command denied by user" at durationMs 60016, 60025 and 60029 — within 13 ms of exactly 60 s each time, which is not a human clicking. Passing timeoutSeconds: 1800 does not extend it, since that governs command runtime rather than the approval wait. If that reading is right, an expired dialog reporting as an explicit deny is misleading to both the agent and the user: the agent concludes the user refused, the user believes they granted permission. A distinct errorCode such as approval_timeout would let the caller re-request instead of backing off.

  2. Two verbs answer "Unknown app: desktop" on this macOS bridge, though both appear in the commands catalog with full arg docs: request_shell_approval ({"reason":..., "wait":true, "timeoutSec":360}) and bridge_list ({}). If they are Windows-line verbs, the catalog served to a macOS client probably should not advertise them — a cold agent reads the catalog and reasonably assumes they work. Note that request_shell_approval being unavailable is what makes (1) unrecoverable: there is no way to ask for a longer-lived grant, and shell_auto_approve correctly refuses AI callers by design.

Workaround for anyone hitting this

Install KiCad manually, then kicad_list_versions to re-detect:

https://mirrors.mit.edu/kicad/osx/stable/kicad-unified-universal-10.0.6.dmg   (1.34 GB, universal)

Mount, copy to /Applications, then xattr -dr com.apple.quarantine /Applications/KiCad.

3 Replies

John Lauer · 1mo ago

Thanks Kyle, this is a precise report and I chased it to the component that actually threw.

It is not the KiCad Bridge's code. Two facts:

  1. The hint you quoted ("macOS: universal DMG into /Applications/KiCad, de-quarantined") and any DMG install path have never existed in this repository. I checked the tree and the whole git history. The KiCad Bridge's own kicad_readiness hint reads differently ("No KiCad installs found. KiCad is the user's host app, so Bridge won't silently auto-install it").
  2. The KiCad Bridge's kicad_upgrade refuses every non-Windows platform with unsupported_platform before it downloads anything. Yours ran for 71 s and 80 s and then hit a Python NameError, which means a different handler with a macOS branch.

So the kicad_* verbs you reached on that Mac are the macOS Adom Bridge's own KiCad support, and the missing import subprocess is there. Moved, with your report verbatim and the suggested smoke test on a KiCad-less runner: adom/adom-bridge-macos#2 (the NameError and the two catalogued verbs answering "Unknown app: desktop"), and adom/adom-bridge#202 (the 60 s approval expiry reported as a user deny, which is ab's approval flow). If the macOS bridge owner comes back saying the Mac does run a KiCad Bridge build, I take it back here.

One thing that IS mine, and I have changed it. The KiCad Bridge's published manifest offers a Windows-only native zip and did not say so: the platforms block (macos.supported:false, with the reason) was in the zip's own bridge.json but not in the page manifest a macOS installer reads. The manifest writer now carries it, so a Mac can refuse the install with a reason instead of ending up with something that cannot run. It goes out with the next release.

Closing here as moved; the two linked issues carry it from now on.

John Lauer closed this · 1mo ago
John Lauer · 1mo ago

Follow-up for Kyle: the approval-expiry half of this shipped in Adom Bridge insiders 2.1.132 (adom/adom-bridge#202, closed with proof). An unanswered prompt now answers errorCode approval_timeout with a message that says nobody answered (not a deny); a real Deny is approval_denied. For a long install pass approvalWaitSec: 600 on the shell_execute call, or run request_shell_approval {wait:true, timeoutSec:600} first and retry once it answers granted. The dashboard-port item (#201) is queued for the build after 2.1.131, and the macOS kicad_upgrade NameError (adom/adom-bridge-macos#2) has no reply yet.

Drew Owens · 15d ago

Still reproducible on macOS through the macOS manifest, 2026-10-26.

adom-bridge-macos 1.9.224 · kicad-bridge 0.11.1 (from adom-bridge-kicad-manifest-macos.json; bridge_check_updates reports 0.11.1 as the latest there) · macOS 26.3.1, Apple silicon · no KiCad installed

So a Mac on this manifest never receives the fixed 1.0.x bridge. kicad_upgrade '{}' downloaded kicad-unified-universal-10.0.7.dmg (1,404,855,631 bytes, complete, left in $TMPDIR) and then failed in the copy step:

File "~/Library/Application Support/Adom Bridge/bridges-cache/kicad/handlers/upgrade.py", line 307, in _mac_upgrade
    proc = subprocess.run(
NameError: name 'subprocess' is not defined
During handling of the above exception, another exception occurred:
  File ".../handlers/upgrade.py", line 340, in _mac_upgrade
    except subprocess.TimeoutExpired as e:
NameError: name 'subprocess' is not defined

The relay call itself timed out at 660 s with no payload, so the caller only sees the failure through bridge_log_read.

Workaround that worked: run_script (bash) mounting the cached DMG read-only with hdiutil attach -nobrowse, ditto of its KiCad folder into /Applications/KiCad (4.9 GB), detach, kicad-cli version = 10.0.7. kicad_readiness stayed detected:false until bridge_kill {"name":"kicad"} restarted the bridge (as in #82); it now reports 10.0.

Suggest publishing the fixed bridge to the macOS manifest, or pointing macOS hosts at the main one.

Log in to reply.