Cmd('git') failed due to: exit code(129)
Issue
Error on commit:
Cmd('git') failed due to: exit code(129)
cmdline: git diff --cached --abbrev=40 --full-index --raw -- src\main.ts
stderr: 'error: unknown option `cached'
Version and model info
Platform: Windows (PowerShell 7.4.5) GIT: git version 2.46.0.windows.1
Aider v0.55.1.dev81+gcee34861 Main model: claude-3-5-sonnet-20240620 with diff edit format, prompt cache, infinite output Weak model: claude-3-haiku-20240307
I found the issue: a new repo clone wasn't flagged as safe. Maybe add checks to catch that.
Thanks for trying aider and filing this issue.
For aider, you'll need to use a git that supports --cached. It's a pretty basic option.
Not sure what you mean by the "new repo clone wasn't flagged as safe"?
git only shows the command valid in the given context. So as the repo wasn't set to save yet, it reported that --cached wasn't available. After I added the folder, --cached showed up as possible.
git diff --cached = ERROR
git config --global --add safe.directory F:/GitHub/my-project
git diff --cached = OK
I had just clone the repo. Added and started venv, installed and started Aider. Then the bug came.
Any idea why git diff --cached would fail when git doesn't consider the directory safe?
Any idea why
git diff --cachedwould fail when git doesn't consider the directory safe?
Yes. Because if the directory is not marked safe, the .git directory seems to get hidden and then git diff --cached produces this irritating error message, apparently because diff is a sub command and --cached does not make any sense in this case. git error messages are very, very special sometimes.
I can confirm that git config --global --add safe.directory F:/GitHub/my-project fixed this super annoying issue for me. Thank 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.
git only shows the command valid in the given context. So as the repo wasn't set to save yet, it reported that --cached wasn't available. After I added the folder, --cached showed up as possible.
git diff --cached = ERROR git config --global --add safe.directory F:/GitHub/my-project git diff --cached = OKI had just clone the repo. Added and started venv, installed and started Aider. Then the bug came.
Thanks @SShadowS for sharing this!!! I was going nuts trying to figure out what was going on.
@paul-gauthier thanks for building aider! It's an incredible tool! I am using it in docker. The service looks like this in my docker-compose.yml:
aider:
stdin_open: true
tty: true
entrypoint: /bin/bash
volumes:
- ./.aider:/app
- ./src/my-git-repo:/app/repo
image: paulgauthier/aider-full
So marking the git repository solves the problem inside the docker container
git config --global --add safe.directory /app/repo
It might be that a new repo created by aider has no issues. Maybe it only applies repos not created by aider. Anyways, the above git command gets rid of this:
Cmd('git') failed due to: exit code(129)
cmdline: git diff --cached --abbrev=40 --full-index --raw -- ###PATH/FILE AIDER IS EDITING GOES HERE###
stderr: 'error: unknown option `cached'
usage: git diff --no-index [<options>] <path> <path>