Deduplicate the unified mount list before invoking podman#73
Open
yarikoptic wants to merge 1 commit into
Open
Conversation
When the same host path appeared both as a default yolo mount (CWD, ~/.claude, ~/.gitconfig, worktree-original-repo) and in a config entry — or in multiple config entries / on the CLI — yolo previously passed two `-v` flags for it, with conflicting SELinux labels (default `:z` vs config-derived `:Z`), and podman refused to start. In my case it was the skills/ folder which I wanted to make available to all sessions but then I wanted to work on it in yolo as well, which caused duplication and yolo did not start. Restructure the mount handling so that, right before composing the `podman run` command, all `-v` sources are gathered into one ordered list and deduplicated by host path (the first colon-delimited segment of the spec). When two entries share a host path, the LATER one in the list wins: 1. Config volumes (YOLO_PODMAN_VOLUMES, lowest) 2. Default yolo mounts (claude home, gitconfig, workspace) 3. Worktree-original-repo (when --worktree=bind / ask-confirmed) 4. CLI -v / --volume (explicit user intent, highest) So: - workspace (CWD) overrides a config entry for the same path — keeping the `:z` (shared/rw) label needed for the directory you're working in - worktree-original beats a config entry for that path - a CLI `-v` overrides config and default mounts (explicit override wins) - user-wide + project configs that list the same path collapse Comparison is exact-string on host paths after `expand_volume`. So: - `~/data` and `$HOME/data` collapse (same expanded string) - `/foo/bar` and `/foo//bar` do not (no canonicalisation) - `~/data` (rw) and `~/data::ro` collapse to the later one when present Implementation changes: - New `dedup_mount_specs` function (sourceable, testable) that walks a flat list of specs and emits the last-occurrence-per-host-path subset - Config volume processing populates a flat `CONFIG_MOUNT_SPECS` array instead of prepending into `PODMAN_ARGS` - Worktree handling populates `WORKTREE_MOUNT_SPECS` (specs only; previously stored as alternating `-v <spec>` pairs) - Right before `podman run`, CLI `-v` / `--volume` (also `-v=X` and `--volume=X`) are extracted from `PODMAN_ARGS` into `CLI_MOUNT_SPECS`; non-mount args stay in `PODMAN_ARGS` - The four sources (config / defaults / worktree / CLI) are concatenated in priority order and passed to `dedup_mount_specs`; the result is expanded back into `-v <spec>` pairs and inserted into `podman run` ## Files - `bin/yolo` — `dedup_mount_specs` helper, unified mount-list assembly and dedup right before `podman run`; CLI `-v`/`--volume` extraction - `tests/yolo.bats` — function-level tests for `dedup_mount_specs` plus end-to-end cases: cross-config dedup, intra-config dedup, CWD vs config, ~/.claude vs config, CLI vs config, CLI vs workspace, and worktree-original-repo vs config - `SPEC.md` — §3 "Volume Mount Handling" now documents the unified dedup, priority order, and CLI extraction; §2 just points at §3 Co-Authored-By: Claude Code 2.1.143 / Claude Opus 4.7 <noreply@anthropic.com>
pr-scout: spec-audit✅ Spec update matches code changesCode change summaryHere's a summary of the new or changed functionality:
VerdictPASS The spec update accurately and comprehensively describes the code changes from a user-visible perspective.
|
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.
When the same host path appeared both as a default yolo mount (CWD, ~/.claude, ~/.gitconfig, worktree-original-repo) and in a config entry — or in multiple config entries / on the CLI — yolo previously passed two
-vflags for it, with conflicting SELinux labels (default:zvs config-derived:Z), and podman refused to start. In my case it was the skills/ folder (for https://github.com/con/skills/) which I wanted to make available to all sessions but then I wanted to work on it in yolo as well, which caused duplication and yolo did not start.Restructure the mount handling so that, right before composing the
podman runcommand, all-vsources are gathered into one ordered list and deduplicated by host path (the first colon-delimited segment of the spec). When two entries share a host path, the LATER one in the list wins:So:
:z(shared/rw) label needed for the directory you're working in-voverrides config and default mounts (explicit override wins)Comparison is exact-string on host paths after
expand_volume. So:~/dataand$HOME/datacollapse (same expanded string)/foo/barand/foo//bardo not (no canonicalisation)~/data(rw) and~/data::rocollapse to the later one when presentImplementation changes:
dedup_mount_specsfunction (sourceable, testable) that walks a flat list of specs and emits the last-occurrence-per-host-path subsetCONFIG_MOUNT_SPECSarray instead of prepending intoPODMAN_ARGSWORKTREE_MOUNT_SPECS(specs only; previously stored as alternating-v <spec>pairs)podman run, CLI-v/--volume(also-v=Xand--volume=X) are extracted fromPODMAN_ARGSintoCLI_MOUNT_SPECS; non-mount args stay inPODMAN_ARGSdedup_mount_specs; the result is expanded back into-v <spec>pairs and inserted intopodman runFiles
bin/yolo—dedup_mount_specshelper, unified mount-list assembly and dedup right beforepodman run; CLI-v/--volumeextractiontests/yolo.bats— function-level tests fordedup_mount_specsplus end-to-end cases: cross-config dedup, intra-config dedup, CWD vs config, ~/.claude vs config, CLI vs config, CLI vs workspace, and worktree-original-repo vs configSPEC.md— §3 "Volume Mount Handling" now documents the unified dedup, priority order, and CLI extraction; §2 just points at §3