Repository navigation
fix(cli): start local service with read-only config - #56539
harshitsharmaaaa wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
ba8aed3 to
c13f84f
Compare
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #56359
Type of change
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.tsto 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?
Screenshots / recordings
Not applicable. This change affects CLI service startup behavior and does not introduce UI changes.
Checklist
Added by the opencode bot (AI-generated).
Fixes #56359