fix(spawn): make Cursor local mode work on macOS (and any non-Linux OS)#3422
Merged
Merged
Conversation
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6 tasks
28ff176 to
fe2907d
Compare
fe2907d to
2a49db3
Compare
2 tasks
475ef82 to
5f193ec
Compare
2a49db3 to
7290220
Compare
1 task
5f193ec to
4f96dbc
Compare
louisgv
reviewed
May 21, 2026
Contributor
There was a problem hiding this comment.
a bit of a weird diff. (?)..
- Detect OS/arch at runtime for cross-platform Caddy installation - Install Caddy to ~/.local/bin (user-writable on all platforms) - Fix /etc/hosts configuration to work on both macOS and Linux - Replace setsid (Linux-only) with nohup (POSIX) - Ensure ~/.local/bin is in PATH for Caddy commands - Add comprehensive comments explaining platform-specific choices Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4f96dbc to
7a5cf90
Compare
louisgv
approved these changes
May 21, 2026
7290220 to
08799bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
spawn cursor localfails on macOS with four cascading errors:These occur in packages/cli/src/shared/cursor-proxy.ts (setupCursorProxy and startCursorProxy). Even though local/agents.ts wires runLocal as the runServer callback, the proxy scripts it constructs were written exclusively for Linux:
setupCursorProxycallshttps://caddyserver.com/api/download?os=linux&arch=amd64unconditionally. On macOS this downloads a Linux ELF binary that immediately fails to execute./usr/local/bin/caddy. On macOS this directory either doesn't exist (no Homebrew) or is owned by a system process, sochmod +ximmediately fails without sudo./etc/hostsis read-only without root on macOS — the domain-spoofing step runs echo"127.0.0.1 ..." >> /etc/hostsdirectly, which fails with Permission denied because/etc/hostsis only writable by root on macOS (unlike some Linux setups where the invoking user may own it).setsidis Linux-only — the non-systemd fallback in startCursorProxy callssetsidto detach backend processes.setsidis a util-linux command; it doesn't ship on macOS (or BSD, or Windows).nohup … &is the portable equivalent.The downstream symptom of all four: Caddy never starts, the proxy is never listening, and Cursor's auth exchange fails — which surfaces as "The provided API key is invalid" even when the key is valid.
Fix
process.platformandprocess.arch(already available in Bun) to select the correct Caddy download (os=darwin, arch=arm64 | amd64 for macOS; os=linux for Linux).~/.local/bin/caddy(guaranteed writable, always exists aftermkdir -p) instead of/usr/local/bin/. Add~/.local/bintoPATHin the execution environment.sudofor/etc/hosts— prefix thesedandechohost entries withsudo. Wrap in a try/catch with a clear fallback message ifsudoisn't available (some sandboxed environments).setsidwithnohup— swapsetsid $NODE ...fornohup $NODE ... < /dev/null >> /tmp/cursor-proxy.log 2>&1 &in the non-systemd branch.nohupis POSIX and present on macOS, Linux, and BSD.Affected code
packages/cli/src/shared/cursor-proxy.ts—installCaddyshell fragment,hosts-spoofingfragment,startCursorProxynon-systemd branchTesting
Tested on macOS (Apple Silicon, M3) with SPAWN_CLI_DIR pointing at a local build:
spawn cursor localcompletes all setup steps without errors