Ensure user is in docker group before sg docker, revert workarounds

The root cause of broken keyboard navigation was sg docker prompting
for the (unset) group password when the user wasn't in the docker
group. Fix by running sudo usermod -aG docker before sg docker.

This makes the stty sane calls and p.confirm workaround unnecessary,
so revert those. Also remove the manual docker group instruction from
nanoclaw.sh since container.ts handles it automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Koshkoshinsk
2026-04-29 21:12:14 +00:00
parent dec1be6adc
commit 0a18c1d21a

View File

@@ -127,11 +127,22 @@ export async function run(args: string[]): Promise<void> {
} }
// Socket is unreachable due to group perms — current shell's supplementary // Socket is unreachable due to group perms — current shell's supplementary
// groups are fixed at login, so `usermod -aG docker` (via install-docker.sh // groups are fixed at login, so `usermod -aG docker` doesn't affect us
// or a prior install) doesn't affect us until next login. Re-exec this // until next login. Ensure the user is in the docker group (install-docker.sh
// step under `sg docker` so the child picks up docker as its primary // does this on fresh installs, but skips when Docker is already present),
// group and can talk to /var/run/docker.sock without a logout. // then re-exec under `sg docker` so the child picks up docker as its
// primary group and can talk to /var/run/docker.sock without a logout.
if (status === 'no-permission' && getPlatform() === 'linux' && commandExists('sg')) { if (status === 'no-permission' && getPlatform() === 'linux' && commandExists('sg')) {
// Ensure the current user is in the docker group — without this,
// sg will ask for the (typically unset) group password and fail.
const inGroup = spawnSync('id', ['-nG'], { encoding: 'utf-8' });
if (!(inGroup.stdout ?? '').split(/\s+/).includes('docker')) {
log.info('Adding current user to docker group');
spawnSync('sudo', ['usermod', '-aG', 'docker', process.env.USER ?? ''], {
stdio: 'inherit',
});
}
log.info('Re-executing container step under `sg docker`'); log.info('Re-executing container step under `sg docker`');
const res = spawnSync( const res = spawnSync(
'sg', 'sg',