/voice says "requires SoX" on headless hosts where SoX IS installed (detection runs `rec --version`, which fails with no capture device)
Summary
On a headless Linux host (no audio capture device), /voice reports "Voice mode requires SoX for audio recording. Install it with: sudo apt-get install sox" even when SoX is fully installed. The message sends users to reinstall a package that is already present; the real cause is the absence of an audio capture device, which the message never mentions.
Environment
- Claude Code
2.1.181 - Linux (headless VPS, accessed over SSH) —
sox 14.4.2 which sox/which rec/which play/which arecordall resolve under/usr/bin- No ALSA cards (
/proc/asound/cardsdoes not exist), PulseAudio not running
What happens
❯ /voice
⎿ Voice mode requires SoX for audio recording. Install it with: sudo apt-get install sox
$ sudo apt-get install sox
sox is already the newest version (14.4.2+git20190427-4build4).
So the user dutifully (re)installs SoX, and nothing changes.
Root cause
The detection function checks SoX availability by executing rec --version and requiring exit code 0, rather than checking whether the binary exists:
async function KDe(e){ return (await Nn(e,["--version"],{timeout:3000,useCwd:false})).code===0 }
// ...
if(!await KDe("rec")){
// "Voice mode requires SoX for audio recording. Install it with: ..."
}
rec is SoX's recording front-end, so it tries to open the default capture device just to parse its arguments. On a host with no capture device that fails:
$ rec --version
ALSA lib pulse.c: PulseAudio: Unable to connect: Connection refused
rec FAIL sox: Sorry, there is no default audio device configured
$ echo $?
1
By contrast the same SoX binary in non-capture roles exits 0:
$ sox --version # sox: SoX v14.4.2 -> exit 0
$ play --version # play: SoX v14.4.2 -> exit 0
$ rec --version # -> exit 1 (no default capture device)
So KDe("rec") returns false, and the code concludes "SoX not installed" when SoX is installed but there is no microphone / capture device. The arecord fallback (OLl() spawning arecord ... /dev/null) also fails on a card-less system and falls through to the same rec branch.
Why the wording matters
The conditions "SoX is not installed" and "SoX is installed but cannot open a capture device" are different problems with different fixes, but they collapse to the same message. On a headless server the suggested fix (apt-get install sox) can never resolve it, because the box has no microphone — installing packages cannot conjure hardware.
Suggested fix
When rec --version fails but sox/play are present (i.e. SoX is installed), report the capture-device problem instead of "install SoX". Roughly:
- If
command -v sox(orplay) succeeds butrec --versionexits non-zero → message like:
> Voice mode needs an audio capture device, but none was found (SoX is installed). This usually means you're on a headless/remote host with no microphone. Run Claude Code on a machine with a mic to use voice input.
- Keep the existing "install SoX" message only when the SoX binaries are genuinely absent.
This would have saved a real round-trip of "reinstall the package that's already installed."
Repro
- On a headless Linux host with
soxinstalled but no audio capture device (no/proc/asound/cards, no PulseAudio). - Run
/voice. - Observe the "requires SoX … apt-get install sox" message despite SoX being installed.