VM setup: catch missing AVX2 up front and stop the sign-in step hanging - #29
Merged
Merged
Conversation
Run the auth status check detached from the terminal (stdin /dev/null) and bounded by a 20s timeout, parsing the JSON rather than the exit code. Carry on to claude auth login if the status is unknown, suppress console-browser takeover on headless VMs, and treat EOF at a prompt as the default instead of aborting.
Claude Code's Bun-compiled binary spins at 100% CPU instead of failing when AVX2 is missing, which is what hung the sign-in step on a Proxmox VM using the x86-64-v2-AES CPU type. Check /proc/cpuinfo in preflight and explain the VM CPU-type fix; ALLOW_NO_AVX2=1 overrides.
Merged
4 tasks
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.
Summary
Root cause found: the VM's CPU type was Proxmox's
x86-64-v2-AES, which doesn't expose AVX/AVX2. Claude Code's Bun-compiled Linux binary doesn't fail cleanly without AVX2:claude auth status --jsonspun with one thread at 100% CPU for 29+ minutes, and did the same with stdin detached and with an emptyHOME. Setting the VM's CPU type tohostfixed it; the same command now returns instantly.New: AVX2 preflight check
preflightchecks/proc/cpuinfoforavx2before installing anything. If it's missing, the script stops with the CPU model and the fix: set the VM CPU type tohost(or at leastx86-64-v3), then fully stop and start the VM, because a guest reboot isn't enough.ALLOW_NO_AVX2=1overrides it with a warning; ARM is skipped.Hardening of the sign-in step (defence in depth)
A real run of
claude-code-vm-setup.shgot stuck right after>>> Signing in to Claude Code, with no further output. The "Open the URL below…" line never printed, so it was hanging in the sign-in status check, not inclaude auth login.That check ran
claude auth status --json | jq …with stdin still attached to the user's terminal and stdout piped. Anything that made the CLI wait there would sit there silently: a prompt it printed (invisible, because stdout went to jq), or a slow first-run/network step. I couldn't reproduce the exact trigger in a clean Ubuntu 24.04 run (same apt build, 2.1.274, under a real PTY), so this makes the step impossible to hang silently, whatever the cause:claude_auth_statehelper, used by both the sign-in step and the health check:stdin </dev/null, so a hidden prompt fails immediately instead of waiting on the terminal;timeout 20, so a stuck check reports "unknown" and the script carries on toclaude auth login(or warns in the health check) instead of hanging;auth statusexits 1 when signed out.DISPLAY/WAYLAND_DISPLAY, runs the login withBROWSER=true, so a console browser set aswww-browser(w3m/lynx) can't take over the terminal; the printed URL is used instead.Failed during: startup.Test plan
claude auth statusmain thread at 99.9% CPU, no network activity, no reads; reproduced with</dev/nulland with an emptyHOME(rc=124after 30s); fixed by changing the CPU type tohost(returns instantly)check_cpuunit cases: AVX2 present → pass; missing → stops with instructions; missing +ALLOW_NO_AVX2=1→ warns and continues; arm64 → skippedshellcheckcleanclaude_auth_stateagainst the real CLI (signed out →out) and stub CLIs: signed-in →in:claude.ai; prompts on stdin → returns immediately, including under a real TTY; garbage output →unknown; hangs →unknownafter 20subuntu:24.04container, apt install route: status check runs, instructions print, sign-in URL appears, waits at "Paste code here"