Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions bin/yolo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions tests/yolo.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading