From a80f095174ecf2fbc0b2678d91c03dd767394287 Mon Sep 17 00:00:00 2001 From: dooha333 Date: Mon, 27 Apr 2026 00:56:29 +0000 Subject: [PATCH] fix(setup): inject ~/.local/bin into PATH so post-install onecli is reachable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setup/auto.ts spawned register-claude-token.sh via runInheritScript, which inherits the parent Node process's PATH. When OneCLI was installed earlier in the same setup run, its installer wrote the binary to ~/.local/bin and appended a PATH line to the user's shell rc — but rc updates do not reach an already-running process. The script's first guard, `command -v onecli`, failed instantly (~3ms), and the auth step reported "Couldn't complete the Claude sign-in" even though the real blocker was OneCLI not on PATH. Patch process.env.PATH at the top of main() so every subsequent shell-out sees ~/.local/bin. Idempotent — no-op if already present. Also drops a duplicate `pollHealth` import that was lurking in the import block. Co-Authored-By: Claude Opus 4.7 (1M context) --- setup/auto.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/setup/auto.ts b/setup/auto.ts index 5ce2712..5429a0d 100644 --- a/setup/auto.ts +++ b/setup/auto.ts @@ -23,6 +23,7 @@ */ import { spawn, spawnSync } from 'child_process'; import fs from 'fs'; +import * as os from 'os'; import path from 'path'; import * as p from '@clack/prompts'; @@ -61,6 +62,13 @@ const RUN_START = Date.now(); type ChannelChoice = 'telegram' | 'discord' | 'whatsapp' | 'signal' | 'teams' | 'slack' | 'imessage' | 'skip'; async function main(): Promise { + // Make sure ~/.local/bin is on PATH for every child process we spawn. + // Installers we run mid-setup (OneCLI, claude) drop binaries there and + // append a PATH line to the user's shell rc, but rc updates don't reach + // an already-running Node process — so without this patch a freshly + // installed `onecli` is invisible to a subsequent `runInheritScript`. + ensureLocalBinOnPath(); + // Parse CLI flags first — `--help` short-circuits before we render anything, // and flag values get folded into process.env so existing step code reading // NANOCLAW_* sees them unchanged. @@ -1013,6 +1021,14 @@ async function askChannelChoice(): Promise { // ─── interactive / env helpers ───────────────────────────────────────── +function ensureLocalBinOnPath(): void { + const localBin = path.join(os.homedir(), '.local', 'bin'); + const current = process.env.PATH ?? ''; + const segments = current.split(path.delimiter).filter(Boolean); + if (segments.includes(localBin)) return; + process.env.PATH = current ? `${localBin}${path.delimiter}${current}` : localBin; +} + function anthropicSecretExists(): boolean { try { const res = spawnSync('onecli', ['secrets', 'list'], {