[BUG] crewai install exits 0 when uv sync fails
Description
crewai install reports a failed install but exits with status 0. install_crew() catches subprocess.CalledProcessError, prints the error, and returns unless the caller passes raise_on_error=True:
lib/cli/src/crewai_cli/install_crew.py:71-80
except subprocess.CalledProcessError as e:
click.echo(f"An error occurred while running the crew: {e}", err=True)
click.echo(e.output, err=True)
if raise_on_error:
raise
The install command uses the default False:
lib/cli/src/crewai_cli/cli.py:652-656
def install(context: click.Context) -> None:
"""Install the Crew."""
from crewai_cli.install_crew import install_crew
install_crew(context.args)
The other callers already pass raise_on_error=True and translate the failure into SystemExit(e.returncode) (deploy/main.py:268, run_crew.py:454-459), so the failure status is lost only on the user-facing crewai install path.
Reproduction
In a project whose dependencies cannot be resolved (an unavailable pin, a private index without credentials, no network, or simply uv missing), run:
crewai install
echo $?
The command prints An error occurred while running the crew: Command '['uv', 'sync']' returned non-zero exit status ... and then prints 0. A CI job or install script therefore treats the project as installed and continues with a stale environment.
Expected behaviour
crewai install should exit with uv's non-zero status (or 1 when the failure is not a CalledProcessError), while keeping the existing error message.
Suggested fix
Pass raise_on_error=True from the command and translate the exception the same way deploy and run do:
try:
install_crew(context.args, raise_on_error=True)
except subprocess.CalledProcessError as e:
raise SystemExit(e.returncode) from e
except Exception:
raise SystemExit(1) from None
Tests
lib/cli/tests/test_install_command.py monkeypatches subprocess.run to raise CalledProcessError(2, ["uv", "sync"]) and asserts the CLI exits with 2 while the error text is still printed. On main it fails with assert 0 == 2.
Prepared with an AI coding agent. Please apply the llm-generated label; this account cannot set repository labels.