Skip to content

fix(install): chown docker scaffold output before the git phase - #1245

Merged
c-vigo merged 2 commits into
devfrom
bugfix/1235-docker-chown-scaffold
Jul 21, 2026
Merged

c-vigo merged 2 commits into
devfrom
bugfix/1235-docker-chown-scaffold

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Root cause

Closes #1235.

Under install.sh --docker, the scaffold container runs as root, so its
bind-mounted output (-v "$PROJECT_PATH:/workspace") lands root-owned on the
host. The host-side git phase (setup_git_repo) then runs against that
still-root-owned tree and fails with .git: Permission denied. That failure is
warn-not-fail by design (CI/fresh-machine friendliness), so the installer
"succeeds" but leaves a root-owned, git-less tree. Before this change there was
no chown anywhere in install.sh (grep -c chown install.sh == 0), so every
docker caller had to repair ownership and git init by hand — the direnv smoke
lane (devkit-smoke-test#286, #1194) carries exactly that workaround.

Fix

After the scaffold container run and before the host-side setup (git phase +
run_user_conf), on the docker runtime only, reuse the same image in a
throwaway container to chown the tree back to the invoking user:

docker run --rm -v "$PROJECT_PATH:/workspace" "$IMAGE" \
    chown -R "$(id -u):$(id -g)" /workspace

The host user usually can't chown root-owned files directly, hence the
second container run. Rootless podman already maps container-root to the
invoking user, so its output is correctly owned — the repair is gated on
[ "$RUNTIME" = "docker" ] and skipped for podman. The step is warn-not-fail to
match the git phase's posture, and it sits after the --preview/--dry-run
early exits so those paths are unaffected. The warn-not-fail git phase itself is
left untouched as the issue requires.

The smoke-lane workaround is intentionally not touched here (per the issue,
that simplification is a follow-up once this releases).

Test evidence (TDD)

New section in tests/bats/install.bats (#1235), exercised against a logging
stub runtime:

  • docker path chowns scaffold output to the invoking user — asserts a
    chown -R <uid>:<gid> /workspace container run is issued on --docker.
  • podman path runs no ownership-repair container — asserts --podman never
    chowns.
  • ownership repair is ordered before the git phase — structural: the chown
    block precedes the setup_git_repo call in source.

RED (test commit d652f95b): docker + ordering tests fail (no chown present).
GREEN (fix commit 49ead96e): all 3 pass; full install.bats suite 102/102 ok.

just precommit (full pre-commit run --all-files): all hooks green.

Refs: #1235

@c-vigo
c-vigo merged commit 53b637e into dev Jul 21, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1235-docker-chown-scaffold branch July 21, 2026 11:37
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.

1 participant