crewAIInc/crewAI · error · ValueError

{self.path} is not a Git repository.

Error message

{self.path} is not a Git repository.

What it means

Raised by Repository.__init__ when the given path is not inside a Git work tree (the `git rev-parse`-backed is_git_repo check fails) — git is installed, but there is no repository at self.path. Deploy flows require a repo to compute remotes/commits, so construction aborts. The message interpolates the offending path.

Source

Thrown at lib/cli/src/crewai_cli/git.py:35

    ".tox/",
    ".venv/",
    "__pycache__/",
    "build/",
    "dist/",
    "env/",
    "venv/",
]


class Repository:
    def __init__(self, path: str = ".", fetch: bool = True) -> None:
        self.path = path

        if not self.is_git_installed():
            raise ValueError("Git is not installed or not found in your PATH.")

        if not self.is_git_repo:
            raise ValueError(f"{self.path} is not a Git repository.")

        if fetch:
            self.fetch()

    @staticmethod
    def is_git_installed() -> bool:
        """Check if Git is installed and available in the system."""
        try:
            subprocess.run(
                ["git", "--version"],  # noqa: S607
                capture_output=True,
                check=True,
                text=True,
            )
            return True
        except (subprocess.CalledProcessError, FileNotFoundError):
            return False

View on GitHub (pinned to 754d7323be)

Solutions

  1. cd into the project and initialize: `git init && git add . && git commit -m 'init'`
  2. Or use Repository.initialize('.') / the CLI flow that creates the repo and initial commit for you
  3. Verify with `git -C <path> status` that the path is a work tree before running deploy
  4. Fix the path argument if you pointed Repository at the wrong directory

Example fix

# before
repo = Repository(path='./my-crew')  # ValueError: ./my-crew is not a Git repository.
# after
repo = Repository.initialize(path='./my-crew')  # inits repo + initial commit, no fetch
Defensive patterns

Strategy: validation

Validate before calling

import subprocess

def is_git_worktree(path: str) -> bool:
    return subprocess.run(
        ["git", "-C", path, "rev-parse", "--is-inside-work-tree"],
        capture_output=True,
    ).returncode == 0

Try / catch

try:
    repo = Repository(path)
except ValueError as e:
    if "is not a Git repository" in str(e):
        repo = Repository.initialize(path)  # or git init manually first
    else:
        raise

Prevention

When it happens

Trigger: Running `crewai deploy create` in a freshly scaffolded crew that has never been `git init`-ed; constructing Repository('/some/dir') where no .git exists; running the CLI one directory above/below the actual repo without git's upward discovery applying (e.g. path explicitly set wrong).

Common situations: New project scaffolds not yet initialized, downloading/copying a project without its .git folder, running deploy commands in a temp/scratch directory, or path typos in programmatic usage.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/55ec97516e06d5e0. Report an issue: GitHub.