Skip to content

Commit b2a5428

Browse files
authored
fix(ci): unset empty UV index env vars to prevent uv errors (llamastack#4012)
Fixes container builds failing with UV index strategy errors when build args are passed with empty values. Docker ARGs declared with empty defaults (ARG UV_INDEX_STRATEGY="") become environment variables with empty string values in RUN commands. UV interprets these as if --index-strategy "" was passed on the command line, causing build failures with "error: a value is required for '--index-strategy <UV_INDEX_STRATEGY>'". This is a footgun because empty string ≠ unset variable, and ARGs silently propagate to all RUN commands, only failing when declared with empty defaults. The fix unsets UV_EXTRA_INDEX_URL and UV_INDEX_STRATEGY at the start of RUN blocks, saves the values early, and only restores them for editable installs with RC dependencies. All other install modes (PyPI, test-pypi, client) now run with a clean environment.
1 parent f8fe301 commit b2a5428

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

containers/Containerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ COPY . /workspace
6464

6565
# Install the client package if it is provided
6666
# NOTE: this is installed before llama-stack since llama-stack depends on llama-stack-client-python
67+
# Unset UV index env vars to ensure we only use PyPI for the client
6768
RUN set -eux; \
69+
unset UV_EXTRA_INDEX_URL UV_INDEX_STRATEGY; \
6870
if [ -n "$LLAMA_STACK_CLIENT_DIR" ]; then \
6971
if [ ! -d "$LLAMA_STACK_CLIENT_DIR" ]; then \
7072
echo "LLAMA_STACK_CLIENT_DIR is set but $LLAMA_STACK_CLIENT_DIR does not exist" >&2; \
@@ -74,18 +76,20 @@ RUN set -eux; \
7476
fi;
7577

7678
# Install llama-stack
77-
# Use UV_EXTRA_INDEX_URL inline only for this step to avoid affecting distribution deps
79+
# Use UV_EXTRA_INDEX_URL inline only for editable install with RC dependencies
7880
RUN set -eux; \
81+
SAVED_UV_EXTRA_INDEX_URL="${UV_EXTRA_INDEX_URL:-}"; \
82+
SAVED_UV_INDEX_STRATEGY="${UV_INDEX_STRATEGY:-}"; \
83+
unset UV_EXTRA_INDEX_URL UV_INDEX_STRATEGY; \
7984
if [ "$INSTALL_MODE" = "editable" ]; then \
8085
if [ ! -d "$LLAMA_STACK_DIR" ]; then \
8186
echo "INSTALL_MODE=editable requires LLAMA_STACK_DIR to point to a directory inside the build context" >&2; \
8287
exit 1; \
8388
fi; \
84-
if [ -n "$UV_EXTRA_INDEX_URL" ] && [ -n "$UV_INDEX_STRATEGY" ]; then \
85-
UV_EXTRA_INDEX_URL="$UV_EXTRA_INDEX_URL" UV_INDEX_STRATEGY="$UV_INDEX_STRATEGY" \
89+
if [ -n "$SAVED_UV_EXTRA_INDEX_URL" ] && [ -n "$SAVED_UV_INDEX_STRATEGY" ]; then \
90+
UV_EXTRA_INDEX_URL="$SAVED_UV_EXTRA_INDEX_URL" UV_INDEX_STRATEGY="$SAVED_UV_INDEX_STRATEGY" \
8691
uv pip install --no-cache-dir -e "$LLAMA_STACK_DIR"; \
8792
else \
88-
unset UV_EXTRA_INDEX_URL UV_INDEX_STRATEGY; \
8993
uv pip install --no-cache-dir -e "$LLAMA_STACK_DIR"; \
9094
fi; \
9195
elif [ "$INSTALL_MODE" = "test-pypi" ]; then \

0 commit comments

Comments
 (0)