From ef9969c2eb6009c21f391bb4b0668478c5870848 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 17 Sep 2026 19:16:15 -0400 Subject: [PATCH] Fix duplicate mount error when YOLO_PODMAN_VOLUMES contains the workspace or claude dir When a user's config (user-wide or per-project) lists a directory that matches the current working directory or ~/.claude, podman rejects the run with "duplicate mount destination". This happened in practice when running yolo from a directory that was also listed in YOLO_PODMAN_VOLUMES (e.g. ~/proj/CON/skills in the user config while invoking yolo from that directory). Defer adding config volumes to PODMAN_ARGS until after WORKSPACE_DIR and CLAUDE_DIR are known, then skip any volume whose container destination matches either of those two mounts, emitting a warning to stderr. Co-Authored-By: Claude Code 2.1.275 / Claude Sonnet 4.6 --- bin/yolo | 22 +++++++++++++++++++--- tests/yolo.bats | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/bin/yolo b/bin/yolo index f382369..2185486 100755 --- a/bin/yolo +++ b/bin/yolo @@ -286,6 +286,9 @@ if [ "$found_separator" = 0 ]; then PODMAN_ARGS=() fi +# Expanded volumes from YOLO_PODMAN_VOLUMES; populated below if USE_CONFIG=1 +_CONFIG_VOLS=() + # Load configuration if requested (after separator logic) if [ "$USE_CONFIG" -eq 1 ]; then # Load user-wide config first @@ -355,10 +358,10 @@ if [ "$USE_CONFIG" -eq 1 ]; then YOLO_PODMAN_OPTIONS=("${_USER_OPTIONS[@]}" "${YOLO_PODMAN_OPTIONS[@]}") YOLO_CLAUDE_ARGS=("${_USER_CLAUDE_ARGS[@]}" "${YOLO_CLAUDE_ARGS[@]}") - # Process volumes and expand shorthand syntax + # Process volumes and expand shorthand syntax (defer adding until workspace + # paths are known so we can deduplicate against the workspace/claude mounts) for vol in "${YOLO_PODMAN_VOLUMES[@]}"; do - expanded=$(expand_volume "$vol") - PODMAN_ARGS=("-v" "$expanded" "${PODMAN_ARGS[@]}") + _CONFIG_VOLS+=("$(expand_volume "$vol")") done # Add podman options @@ -458,6 +461,19 @@ else WORKSPACE_MOUNT="$(pwd):$(pwd):z" fi +# Add config volumes to PODMAN_ARGS, skipping any whose container destination +# duplicates the workspace or claude mounts (prevents "duplicate mount" errors +# when the user's YOLO_PODMAN_VOLUMES includes the current working directory). +for _vol in "${_CONFIG_VOLS[@]}"; do + _dest="${_vol#*:}" # strip host part + _dest="${_dest%%:*}" # strip options part + if [ "$_dest" = "$WORKSPACE_DIR" ] || [ "$_dest" = "$CLAUDE_DIR" ]; then + echo "Warning: skipping duplicate volume mount for destination '$_dest' (already mounted)" >&2 + else + PODMAN_ARGS=("-v" "$_vol" "${PODMAN_ARGS[@]}") + fi +done + # Give a meaningful name based on PWD and the PID to help identifying # all those podman containers # Note: leading periods and underscores are stripped as they're not allowed in container names diff --git a/tests/yolo.bats b/tests/yolo.bats index 9a1f5ed..aa55396 100644 --- a/tests/yolo.bats +++ b/tests/yolo.bats @@ -160,6 +160,40 @@ EOF podman_args_contain "$TEST_HOME/data:$TEST_HOME/data:Z" } +@test "config: volume matching workspace dir is skipped with warning" { + write_user_config << EOF +YOLO_PODMAN_VOLUMES=("$TEST_REPO") +EOF + run_yolo + assert_success + assert_output --partial "Warning: skipping duplicate volume mount" + # workspace is still mounted (via the fixed WORKSPACE_MOUNT) + podman_args_contain "$TEST_REPO:$TEST_REPO:z" +} + +@test "config: volume matching claude dir is skipped with warning" { + write_user_config << EOF +YOLO_PODMAN_VOLUMES=("$TEST_HOME/.claude") +EOF + run_yolo + assert_success + assert_output --partial "Warning: skipping duplicate volume mount" + # claude dir is still mounted + podman_args_contain "$TEST_HOME/.claude:$TEST_HOME/.claude:z" +} + +@test "config: non-conflicting volumes still appear after dedup logic" { + write_user_config << EOF +YOLO_PODMAN_VOLUMES=("$TEST_REPO" "$TEST_HOME/skills") +EOF + run_yolo + assert_success + # workspace duplicate skipped + assert_output --partial "Warning: skipping duplicate volume mount" + # non-conflicting volume still present + podman_args_contain "$TEST_HOME/skills:$TEST_HOME/skills:Z" +} + @test "config: scalar override — project USE_NVIDIA=0 overrides user USE_NVIDIA=1" { write_user_config << 'EOF' USE_NVIDIA=1