Repository navigation
fix(copilot): make the state folder usable without a per-repo step (copilot 0.5.0, copilot-home-writable) - #285
Merged
Merged
Conversation
…opilot 0.5.0, copilot-home-writable) A first copilot run failed with "failed to register ownership for session ... Permission denied" where the Feature's volume is not mounted (Envbuilder ignores Feature mounts and hooks), because COPILOT_HOME named a missing, root-owned path. copilot-home, run by copilot-setup and a new /etc/profile.d snippet, makes the folder exist, belong to the remote user and be mode 700: the volume when it is mounted (~/.copilot linked to it), else ~/.copilot with the Feature path linked to it when root or sudo is there, else COPILOT_HOME=~/.copilot in login shells plus a one-line hint. install.sh pre-creates the folder for the build's remote user; a root-run copilot-setup leaves nothing root-owned. New unit suite (home_test.sh) and scenario home_as_user (uid 1000). Co-Authored-By: Claude Opus 5.5 <claude-opus-5-5@noreply.invalid> Signed-off-by: devhost agent <devhost-agent@noreply.invalid>
…me-writable) The devcontainer CLI remaps vscode to the runner's uid (1001 on GitHub), so the fixed uid failed the home_as_user scenario in CI and stopped its other checks. Co-Authored-By: Claude Opus 5.5 <claude-opus-5-5@noreply.invalid> Signed-off-by: devhost agent <devhost-agent@noreply.invalid>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
copilotFeature (0.4.1 → 0.5.0) makes Copilot's state folder usable on its own, so a consuming repo needs no hand-written~/.copilotstep. A newcopilot-home(insrc/copilot/copilot-home.sh) makes the folder exist, belong to the remote user and be mode 700. Three things run it:copilot-setup, the post-create hook (alsotask copilot:setup);/etc/profile.d/copilot-home.sh;install.shpre-creates the folder for the build's remote user.Why
copilotfailed on first run in a toolshed built by Envbuilder (the-boardroom, user uid 1000):containerEnvpointsCOPILOT_HOMEat/var/lib/devcontainer-features/copilot. Envbuilder honourscontainerEnvbut ignores Feature mounts and runs no Feature hook (ADR 0095). So that path was missing, its parent was root's, andcopilot-setupnever ran. The error reproduces with no login:COPILOT_HOME=<missing root-owned path> copilot -p hiprintsFailed to initialize session: Error: Permission denied (os error 13). With a usable folder, the same command gets past it toNo authentication information found. The new scenario uses this to test the real failure.Where the state goes now
COPILOT_HOMEcopilot-homeCOPILOT_HOME(peitho does)chown -Rto the user (root or sudo), 700.~/.copilotis linked to it; a real~/.copilotis copied in without overwriting and kept as~/.copilot.before-copilot-feature~/.copilot~/.copilotis made 700 and gets what the image folder held. The image folder is replaced by the link, so every process that readscontainerEnvagrees~/.copilotin login shellscopilot-setupprints one line: set"COPILOT_HOME": "<home>/.copilot"inremoteEnv, or mount a volume~/.copilotin login shellssudo chown -R <user> … && sudo chmod 700 …install.shrecorded from_REMOTE_USER/_CONTAINER_USER, else uid 1000.copilot-setupprepares the folder for that user, then re-runs itself as that user (runuser, elsesu), so nothing is left root-owned.Validation
bash test/copilot/unit/home_test.sh(new, Docker-free, also intask test:copilot-unit)devcontainer features test -f copilot --filter home_as_user --skip-autogenerated --skip-duplicated .(new scenario, remote uservscode: uid 1000 in the image, remapped to the runner's uid in CI)task test FEATURE=copilot(autogenerated test plus every scenario, in the devhost's docker-in-docker)copilotautogenerated,official_listed,with_gh,participants,participants_only_copilot,attach,no_taskfile,home_as_user), 0 failed checks; the dind was pruned afterwardstask lintlintpassed. Locally, four suites that this change does not touch (test:ssh-agent-unit,test:cloud-folder-unit,test:claude-unit,test:facilitator-unit) fail the same way on untouchedorigin/mainin the devhost: an environment issue, tracked in the backlogtask docssrc/copilot/README.mdchangedThe
home_as_userscenario checks, as the non-rootvscode(CI run 46890731292 passed it, after 131396a dropped a fixed-uid check that failed on GitHub's uid-1001 runners):vscode's, mode 700 and writable;copilot --versionruns;copilot -pgets past the folder, and the old error still shows on an unusable path (so the check can fail);copilot-setuprun as root leaves nothing root-owned;~/.copilot, andcopilotruns).Envbuilder: this repo's CI runs only the devcontainer CLI path; there is no Envbuilder job, so Envbuilder is played inside the scenario rather than built. The first real Envbuilder check is a rebuild of the-boardroom on 0.5.0.
Consumers (not touched here)
copilot:0mkdir ~/.copilot. To keep the login across Envbuilder rebuilds without a persistent home, mount a volume at/var/lib/devcontainer-features/copilotin the templatecopilot:0copilot:0, setsCOPILOT_HOME=/home/metis/.copilotcopilot-cliFeature plus its own post-create stepcopilot:0would let it drop the~/.copilotlines ofpost-create.sh; that is its own changeThe release is the Operator's to start: it would publish copilot 0.5.0.
Checklist
Signed-off-by:, DCO)versionbumped insrc/copilot/devcontainer-feature.json(0.5.0; ghcr's highest is 0.4.1) and its## [0.5.0]entry added tosrc/copilot/CHANGELOG.mdinstall.shis idempotent and does not assume aremoteUser(it uses the remote user only when that account exists at build)test/copilot/home_as_user.sh,scenarios.json,test/copilot/unit/home_test.sh) andtask test FEATURE=copilotpasses (8/8 scenarios)taskfile.ymlpresent and registered viainstallTaskfile(existing;setup's description updated)task lintpasses (CI; the devhost-only failures are in Validation)NOTES.mdupdated (a new "The state folder" section) andtask docsrun