Skip to content

Commit 9dac6d2

Browse files
fix: inject tool repository credentials in crewai run command
1 parent abf8013 commit 9dac6d2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/crewai/src/crewai/cli/run_crew.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import os
12
import subprocess
23
from enum import Enum
34

45
import click
56
from packaging import version
67

7-
from crewai.cli.utils import read_toml
8+
from crewai.cli.utils import build_env_with_tool_repository_credentials, read_toml
89
from crewai.cli.version import get_crewai_version
910

1011

@@ -55,8 +56,22 @@ def execute_command(crew_type: CrewType) -> None:
5556
"""
5657
command = ["uv", "run", "kickoff" if crew_type == CrewType.FLOW else "run_crew"]
5758

59+
env = os.environ.copy()
5860
try:
59-
subprocess.run(command, capture_output=False, text=True, check=True) # noqa: S603
61+
pyproject_data = read_toml()
62+
sources = pyproject_data.get("tool", {}).get("uv", {}).get("sources", {})
63+
64+
for source_config in sources.values():
65+
if isinstance(source_config, dict):
66+
index = source_config.get("index")
67+
if index:
68+
index_env = build_env_with_tool_repository_credentials(index)
69+
env.update(index_env)
70+
except Exception: # noqa: S110
71+
pass
72+
73+
try:
74+
subprocess.run(command, capture_output=False, text=True, check=True, env=env) # noqa: S603
6075

6176
except subprocess.CalledProcessError as e:
6277
handle_error(e, crew_type)

0 commit comments

Comments
 (0)