From 58586f4f8c6301ea39249dec761a7d8f4d0b7029 Mon Sep 17 00:00:00 2001 From: Reid <61492567+reidliu41@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:26:59 +0800 Subject: [PATCH] fix: update cmd check logic (#1347) # What does this PR do? [Provide a short summary of what this PR does and why. Link to relevant issues if applicable.] Sorry for the https://github.com/meta-llama/llama-stack/pull/1340 logic, it will cause issue if in `non-container` env. ``` Using conda <<<<<<<------ environment: stack + is_command_available docker + command -v docker + printf '\033[0;31mError: docker command not found. Is docker installed and in your PATH?\033[0m' Error: docker command not found. Is docker installed and in your PATH?+ exit 1 ``` [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan [Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.*] [//]: # (## Documentation) Signed-off-by: reidliu Co-authored-by: reidliu --- llama_stack/distribution/start_stack.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/llama_stack/distribution/start_stack.sh b/llama_stack/distribution/start_stack.sh index 4656bebae..713997331 100755 --- a/llama_stack/distribution/start_stack.sh +++ b/llama_stack/distribution/start_stack.sh @@ -100,12 +100,6 @@ esac set -x -# Check if container command is available -if ! is_command_available $CONTAINER_BINARY; then - printf "${RED}Error: ${CONTAINER_BINARY} command not found. Is ${CONTAINER_BINARY} installed and in your PATH?${NC}" >&2 - exit 1 -fi - if [[ "$env_type" == "venv" || "$env_type" == "conda" ]]; then $PYTHON_BINARY -m llama_stack.distribution.server.server \ --yaml-config "$yaml_config" \ @@ -113,6 +107,12 @@ if [[ "$env_type" == "venv" || "$env_type" == "conda" ]]; then $env_vars \ $other_args elif [[ "$env_type" == "container" ]]; then + # Check if container command is available + if ! is_command_available $CONTAINER_BINARY; then + printf "${RED}Error: ${CONTAINER_BINARY} command not found. Is ${CONTAINER_BINARY} installed and in your PATH?${NC}" >&2 + exit 1 + fi + if is_command_available selinuxenabled &> /dev/null && selinuxenabled; then # Disable SELinux labels CONTAINER_OPTS="$CONTAINER_OPTS --security-opt label=disable"