Unresponsive Claude
I recently spent a couple of hours debugging why claude-code
was entirely
unresponsive when launched within a QEMU VM: it wouldn’t register any keyboard
input or show any sign of interactivity. I am sharing the result here so that,
hopefully, I can save your time, dear reader.
tl;dr: This resize
script
from the vm-nogui
NixOS generator was wreaking havoc.
For a bit of context: I only run claude-code
within VMs or containers. On
this occasion, it was running inside a QEMU VM built through
nixos-generators with the
vm-nogui
format. The unresponsiveness was only manifesting there, not within
LXC containers.
Running Claude with --debug
wasn’t very helpful but sometimes would show some
error logs about a resize script and the following error:
'standard input': Inappropriate ioctl for device
Through a bit of trial and error, I noticed that /etc/profile
was sourcing
this script, which should apparently resize the serial console.
The trouble with it is that it will try to run even for non-interactive
sessions, resulting in the above error and in Claude freezing completely.
I solved the issue by leaving the resize
script available to the
system (in case I need to run it manually) but removing the automation for it
in /etc/profile
:
# Overwrite `loginShellInit` since `resize` does more harm than good
# https://github.com/nix-community/nixos-generators/blob/032decf9db65efed428afd2fa39d80f7089085eb/formats/vm-nogui.nix#L20C3-L20C29
environment.loginShellInit = lib.mkForce "";