Skip to content

[Bug]: container system start under launchd (brew services) loops on the default-kernel prompt with no TTY #2489

Open

Description

@djbclark

Update 2026-11-12: the restart loop came from a stale Homebrew plist (no --disable-kernel-install, KeepAlive); the upgrade did not remove the kernel. What remains: with no TTY, container system start prompts, then exits 1. See this comment.

Summary

When no default kernel is configured, container system start prompts Install the recommended default kernel ...? [Y/n]:. Run from launchd (Homebrew's brew services agent runs exactly container system start) there is no TTY, so it fails with Error: failed to read user input. The apiserver then never comes up at login, and KeepAlive restarts it into the same failure.

Steps to reproduce

How I hit it (not yet reduced to a clean repro):

  1. Upgrade container with Homebrew (1.4.x to 1.7.1_1) on a machine where no default kernel was configured afterwards.
  2. brew services start container (the LaunchAgent's ProgramArguments are /opt/homebrew/opt/container/bin/container system start).
  3. Log in, or wait for launchd to start it.

Actual behavior

/opt/homebrew/var/log/container.log repeats, 153 times here:

Launching container-apiserver...
Testing access to container-apiserver...
Verifying machine API server is running...
No default kernel configured.
Install the recommended default kernel from [https://github.com/kata-containers/kata-containers/releases/download/3.28.0/kata-static-3.28.0-arm64.tar.zst]? [Y/n]: Error: failed to read user input

container commands then report that the apiserver is not running. Running container system start once in a terminal and answering Y fixes it.

Expected behavior

With no TTY on stdin, container system start should not prompt. It could install the recommended kernel by default, or fail once with a clear message naming the command to run, rather than leaving the service in a restart loop.

Environment

  1. macOS 27.2 (26B123), Apple silicon
  2. container 1.7.1 (Homebrew container 1.7.1_1)

Found and written up with an AI coding assistant; I checked the log and the plist myself.

Activity

  1. resker commented on Nov 11, 2026

    @resker

    I'd suggest that in SystemStart, when neither --enable-kernel-install nor --disable-kernel-install is given and stdin isn't a TTY:

    • Don't prompt.
    • Skip the install and log a warning naming container system kernel set --recommended and --enable-kernel-install.
    • Finish starting, as happens today when you answer "n", so the services stay up and launchd stops restarting into the same failure.

    Installing by default would also fix it - but the downside is a background service downloading a kernel nobody asked for, and the network may not be up yet at login, which brings the loop back.

    Tests: pull the decision (flag, TTY) into a small function with unit tests for each case, plus an integration test that runs system start with stdin from /dev/null and no kernel, and expects it to succeed without installing one.

    Separately, the Homebrew formula has passed --disable-kernel-install in its service block since September (360a028), so a service plist written before then may be what hit this. brew services restart container should regenerate it.

    Let me know if that works and I'll submit a PR.

  2. djbclark commented on Nov 12, 2026

    @djbclark
    Author

    TL;DR: Restarting the Homebrew service fixed my setup. I had mistaken old log errors for a new upgrade problem — there’s no evidence the upgrade deleted my kernel. The no-terminal prompt bug is still real and reproducible, so I support your proposed fix, with a clear warning when the kernel is missing.


    Thanks @resker — brew services restart container worked. I investigated further and need to correct parts of my original report.

    1. My LaunchAgent was stale: it lacked --disable-kernel-install and had KeepAlive (Homebrew's true, which I had locally changed to { SuccessfulExit = false; } to stop the launcher respawning). brew services restart container regenerated it with the flag and no KeepAlive, matching your linked Homebrew change. That change also removed keep_alive true, which matters because this is a bootstrap command that exits after registering the actual services.

    2. I cannot substantiate the claim that the upgrade removed my kernel. The installed kernel and its default symlink both have August 21 creation/modification timestamps. All 153 prompt errors occur at the beginning of a log created August 21; the saved log's last modification predates installation of the November 9 Homebrew package. These are historical errors, not evidence of a kernel disappearing during that upgrade.

    3. I reproduced the actual CLI defect on container 1.7.1 / macOS 27.2 by temporarily moving kernels/default.kernel-arm64 aside, leaving the kernel binary and cached images intact, and starting with stdin connected to /dev/null:

    Check Result
    container system start </dev/null Exit 1, failed to read user input
    container system status immediately afterward Exit 0, running: the API server had started despite the prompt failure
    container system start --disable-kernel-install </dev/null Exit 0, no prompt
    container run --rm ubuntu:24.04 /bin/true with the default symlink still absent Exit 1, default kernel not configured
    Restore the original symlink; repeat start and run Both succeed

    This used existing application data with a deliberately absent default-kernel link, not a completely fresh installation. The original kernel was restored and its SHA-256 was unchanged.

    1. A separate experiment reproduced the service-not-running symptom without losing any kernel: running Homebrew's installed ensure-container-stopped.sh -a (the formula's post-install step) unregistered the API server while the Homebrew bootstrap job remained completed. The default kernel's target, timestamp and SHA-256 stayed unchanged. Restarting the Homebrew service restored operation. This establishes a plausible independent explanation for the upgrade-time outage, not definitive proof of the historical sequence. The restart command returned before API readiness, so an immediate status check briefly still reported it unavailable.

    I support the proposed no-TTY fallback as the focused fix for this issue. Could the warning explicitly distinguish “services started” from “default kernel missing; containers using it cannot start”, and name the repair command? I would also test that explicit enable/disable flags retain their behavior.

    Structured reporting of kernel/base-filesystem readiness would be a useful optional follow-up. I would keep that and any broader provisioning behavior separate from this fix; the current Homebrew configuration resolves my local startup problem.

    Investigated with an AI coding assistant using local filesystem evidence and live CLI tests.

  3. jaeyeonme commented on Nov 12, 2026

    @jaeyeonme

    I'd like to work on this, following the approach @resker suggested, unless @resker is already on it.

    Plan: when neither --enable-kernel-install nor --disable-kernel-install is given and stdin is not a TTY, system start skips the prompt and the kernel install, logs a warning that points to container system kernel set --recommended and --enable-kernel-install, and exits successfully, as it does today when the answer is "n". Interactive runs and runs with either flag keep their current behavior.

    I'd move the decision into a small function with unit tests for each case, and update the --enable-kernel-install description in docs/command-reference.md. If you'd prefer a different behavior for the non-TTY case, such as installing by default, I'll follow that.

  4. resker commented on Nov 12, 2026

    @resker

    Absolutely go ahead — haven't started anything. Happy to review though and +1 to @djbclark's points wrt the warning & explicit flags' behavior covered by tests.

  5. jaeyeonme commented on Nov 13, 2026

    @jaeyeonme

    One change from the plan above. While implementing it I found public CI workflows and scripts that pipe an answer into the prompt, for example yes | container system start and printf 'Y\n' | container system start. Skipping whenever stdin is not a TTY would make those exit 0 without installing a kernel.

    So the change is narrower: system start still prompts and reads the answer as it does today, and a piped answer keeps working. Only when no answer can be read and stdin is not a TTY (the launchd case, where stdin is /dev/null) does it log the warning and exit successfully instead of failing. With either flag there is still no prompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions