aider icon indicating copy to clipboard operation
aider copied to clipboard

Uncaught GitCommandNotFound in cmd.py line 1276

Open altjx opened this issue 11 months ago • 5 comments

Aider version: 0.77.0 Python version: 3.12.8 Platform: macOS-15.3.1-arm64-64bit Python implementation: CPython Virtual environment: Yes OS: Darwin 24.3.0 (64bit) Git information unavailable

An uncaught exception occurred:

Traceback (most recent call last):
  File "cmd.py", line 1262, in execute
    proc = safer_popen(
           ^^^^^^^^^^^^
  File "subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 723, in main
    git_root = setup_git(git_root, io)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 130, in setup_git
    user_name = repo.git.config("--get", "user.name") or None
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cmd.py", line 986, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cmd.py", line 1599, in _call_process
    return self.execute(call, **exec_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cmd.py", line 1276, in execute
    raise GitCommandNotFound(redacted_command, err) from err
git.exc.GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[Errno 2] No such file or directory: 'git'')
  cmdline: git config --get user.name

Tried running aider, which generated an exception. Tried having it automatically open a PR, and that failed too. Running macOS Sequoia 15.3.1 on a Mac Studio with an M2 Ultra. I also have git and everything else installed to manage my github repo from the CLI, FWIW.

Start to finish from install to error

Image

Hope this information helps!

altjx avatar Mar 14 '25 11:03 altjx

SorThanks for trying aider and filing this issue.

The fix is available in the main branch. You can get it by installing the latest version from github:

aider --install-main-branch

# or...

python -m pip install --upgrade --upgrade-strategy only-if-needed git+https://github.com/Aider-AI/aider.git

If you have a chance to try it, let me know if it works better for you. I'm going to close this issue for now, but feel free to add a comment here and I will re-open. Or feel free to file a new issue any time.

paul-gauthier avatar Mar 30 '25 21:03 paul-gauthier

Same issue on a fresh 0.80.2.dev11+g3992681b:

# Uncaught GitCommandNotFound in cmd.py line 1276

Aider version: 0.80.2.dev11+g3992681b
Python version: 3.12.9
Platform: macOS-15.4-arm64-64bit
Python implementation: CPython
Virtual environment: Yes
OS: Darwin 24.4.0 (64bit)
Git information unavailable

An uncaught exception occurred:

Traceback (most recent call last): File "cmd.py", line 1262, in execute proc = safer_popen( ^^^^^^^^^^^^ File "subprocess.py", line 1028, in init self._execute_child(args, executable, preexec_fn, close_fds, File "subprocess.py", line 1963, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'git'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "aider", line 8, in sys.exit(main()) ^^^^^^ File "main.py", line 729, in main git_root = setup_git(git_root, io) ^^^^^^^^^^^^^^^^^^^^^^^ File "main.py", line 131, in setup_git user_name = repo.git.config("--get", "user.name") or None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "cmd.py", line 986, in return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "cmd.py", line 1599, in _call_process return self.execute(call, **exec_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "cmd.py", line 1276, in execute raise GitCommandNotFound(redacted_command, err) from err git.exc.GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[Errno 2] No such file or directory: 'git'') cmdline: git config --get user.name


Please consider reporting this bug to help improve aider!
Open a GitHub Issue pre-filled with the above error in your browser? (Y/n) n
Traceback (most recent call last):
  File "/Users/andrei/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/git/cmd.py", line 1262, in execute
    proc = safer_popen(
           ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1028, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Cellar/[email protected]/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1963, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/andrei/.local/bin/aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/andrei/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/main.py", line 729, in main
    git_root = setup_git(git_root, io)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrei/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/aider/main.py", line 131, in setup_git
    user_name = repo.git.config("--get", "user.name") or None
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrei/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/git/cmd.py", line 986, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrei/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/git/cmd.py", line 1599, in _call_process
    return self.execute(call, **exec_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrei/.local/pipx/venvs/aider-chat/lib/python3.12/site-packages/git/cmd.py", line 1276, in execute
    raise GitCommandNotFound(redacted_command, err) from err
git.exc.GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[Errno 2] No such file or directory: 'git'')
  cmdline: git config --get user.name

First upgraded, then installed with python -m pip install --upgrade --upgrade-strategy only-if-needed git+https://github.com/Aider-AI/aider.git

Ceesaxp avatar Apr 01 '25 20:04 Ceesaxp

Thanks I will look into it.

Can you share any settings or switches you are using with aider?

paul-gauthier avatar Apr 01 '25 21:04 paul-gauthier

I typically run it as: aider --edit-format diff --model sonnet --show-diffs --watch-files --no-auto-commits

But the same happens even without switches.

It might be not specific to aider – 0.79.2 from brew also breaks.

Ceesaxp avatar Apr 02 '25 05:04 Ceesaxp

FWIW, after many iterations I have figured out what the issue was.

Here’s what’s happening:

  • I have a $HOME/.env where I define environment vars for various shells and interaction modes.
  • python-dotenv tries to parse your $HOME/.env as an .env file in the format of KEY=VALUE pairs only — no export, no shell syntax.
  • When aider uses python-dotenv.load_dotenv(), it sees export PATH=... and fails to parse it, silently or otherwise, overriding or nullifying my environment, especially the PATH, hence the missing git.

Solution:

  • Move $HOME/.env to $HOME/.env.sh and update rc files to source that instead.
  • Create a clean(er) $HOME/.env that follows the KEY=VALUE syntax to be used tools like aider, direnv, or Docker Compose

Ceesaxp avatar Apr 19 '25 07:04 Ceesaxp