Skip to content

fix(cli): start local service with read-only config - #56539

Open
harshitsharmaaaa wants to merge 1 commit into
anomalyco:devfrom
harshitsharmaaaa:fix/read-only-config-service-startup
Open

harshitsharmaaaa wants to merge 1 commit into
anomalyco:devfrom
harshitsharmaaaa:fix/read-only-config-service-startup

Conversation

@harshitsharmaaaa

@harshitsharmaaaa harshitsharmaaaa commented Oct 17, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #56359

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes local service startup when the configuration directory is read-only.

The service can generate a password when no password is configured, but startup may fail when it attempts to persist that password in a configuration directory that cannot be written to.

This change allows the local service to continue with an ephemeral password when password persistence fails, provided no remote configuration requires the persistence operation to succeed. The password remains available for the running service without requiring a write to the read-only configuration directory.

A regression test has been added to packages/cli/test/service-lifecycle.test.ts to cover starting and stopping a local service with a read-only configuration directory. The test is skipped on Windows and when running as root, where permission restrictions do not prevent writes.

How did you verify your code works?

  • Added a lifecycle regression test covering service startup with a read-only configuration directory.
  • Verified that the service starts successfully and its registration contains the expected port.
  • Verified that the service can be stopped cleanly.

Screenshots / recordings

Not applicable. This change affects CLI service startup behavior and does not introduce UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Fixes #56359

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a real read-only bind mount of ~/.config/opencode (the steps from #56359), serve --service on the base exits with EROFS ... service-local.json.tmp. With this change the server starts and registers under ~/.local/state/opencode, where the password is stored and clients read it, outside the read-only config folder. service status and opencode run connect to it. If remote access is configured, a failed password save still stops the server, which seems right because remote clients need a password that survives restarts. typecheck passes.

Public API: unchanged. The config and registration file formats, CLI commands and flags, and the SDK stay the same.

The only concern is the new test: it fails when run as root. See the inline comment.

Fixes #56359

async () => {
await using home = await serviceHome()
const config = path.join(home.root, "config")
await fs.chmod(config, 0o555)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chmod 0555 has no effect for root, so this test fails when run as root, e.g. in a container. The password is written and line 181 gets { password, port } instead of { port }. I hit exactly this here. Since the fix is a few lines, the simplest option is to drop the test. If you want to keep it, skip it under root (e.g. process.getuid?.() === 0) so it doesn't fail for people running the suite in containers.

@harshitsharmaaaa
harshitsharmaaaa force-pushed the fix/read-only-config-service-startup branch from ba8aed3 to c13f84f Compare October 18, 2026 07:26
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: crash on startup when ~/.config/opencode directory mounted RO

1 participant