Skip to content

Commit ec75a30

Browse files
davindicodeclaude
andcommitted
Fix nano version detection on macOS (pico)
- macOS: detect as "pico" instantly (skip --version which hangs) - Linux: use --version for GNU nano version number - Fallback: report "installed" if binary exists but version unknown - Applied to both tool-versions and system-info endpoints Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d30f533 commit ec75a30

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

app/routes/api/system-info.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export async function loader({ request }: Route.LoaderArgs) {
3737
shell: run("echo $SHELL") || run("echo %COMSPEC%") || null,
3838
node: process.version,
3939
tmux: run("tmux -V")?.replace(/^tmux\s+/i, "") || null,
40-
nano: run("nano -V").match(/nano\s+([\d.]+)/i)?.[1] || null,
40+
nano: os === "darwin"
41+
? (run("which nano") ? "pico" : null)
42+
: (run("nano --version")?.match(/nano\s+([\d.]+)/i)?.[1] || (run("which nano") ? "installed" : null)),
4143
vim: run("vim --version").match(/Vi IMproved\s+([\d.]+)/)?.[1] || null,
4244
git: run("git --version")?.replace(/^git version\s+/i, "") || null,
4345
python: run("python3 --version")?.replace(/^Python\s+/i, "") || run("python --version")?.replace(/^Python\s+/i, "") || null,

app/routes/api/tool-versions.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { execSync } from "child_process";
2+
import { platform } from "os";
23
import type { Route } from "./+types/tool-versions";
34

45
function run(cmd: string): string | null {
56
try {
67
return execSync(cmd, { encoding: "utf-8", timeout: 2000, stdio: ["ignore", "pipe", "pipe"] }).trim();
7-
} catch {
8-
return null;
8+
} catch (err: any) {
9+
// Some commands write to stderr or exit non-zero but still have output
10+
return err?.stdout?.trim() || err?.stderr?.trim() || null;
911
}
1012
}
1113

@@ -14,12 +16,17 @@ function getTmuxVersion(): string | null {
1416
}
1517

1618
function getNanoVersion(): string | null {
17-
// GNU nano supports --version; macOS pico doesn't (hangs), so use -V
18-
// Try to extract from "GNU nano x.y" or similar
19-
const out = run("nano -V");
20-
if (!out) return null;
21-
const match = out.match(/nano\s+([\d.]+)/i);
22-
return match?.[1] || null;
19+
// macOS ships pico instead of GNU nano — skip version check to avoid 2s hang
20+
if (platform() === "darwin") {
21+
return run("which nano") ? "pico" : null;
22+
}
23+
// GNU nano on Linux: --version prints to stdout and exits
24+
const out = run("nano --version");
25+
if (out) {
26+
const match = out.match(/nano\s+([\d.]+)/i);
27+
if (match) return match[1];
28+
}
29+
return run("which nano") ? "installed" : null;
2330
}
2431

2532
function getVimVersion(): string | null {

0 commit comments

Comments
 (0)