From fd2aab8582b23a577148eda5e94ef84ac456fa5f Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Wed, 23 Jul 2025 20:43:33 +0100 Subject: [PATCH] fix: prevent shell redirection issues with pip dependencies (#2867) - Use printf to to escape special characters (e.g. < > ) - Apply escaping to pip_dependencies and special_pip_deps Resolves shell interpretation of >= operators as redirections that were causing build failing to respect versions and unexpected file creation in /app directory. Closes: #2866 ## Test Plan Manually tested, will also be tested by existing CI Signed-off-by: Derek Higgins --- llama_stack/distribution/build_container.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index 1b1fcc33c..6985c1cd0 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -136,16 +136,20 @@ EOF # Add pip dependencies first since llama-stack is what will change most often # so we can reuse layers. if [ -n "$pip_dependencies" ]; then + read -ra pip_args <<< "$pip_dependencies" + quoted_deps=$(printf " %q" "${pip_args[@]}") add_to_container << EOF -RUN $MOUNT_CACHE uv pip install $pip_dependencies +RUN $MOUNT_CACHE uv pip install $quoted_deps EOF fi if [ -n "$special_pip_deps" ]; then IFS='#' read -ra parts <<<"$special_pip_deps" for part in "${parts[@]}"; do + read -ra pip_args <<< "$part" + quoted_deps=$(printf " %q" "${pip_args[@]}") add_to_container <