aider icon indicating copy to clipboard operation
aider copied to clipboard

Cmd('git') failed due to: exit code(129)

Open SShadowS opened this issue 1 year ago • 5 comments

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' image

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

SShadowS avatar Sep 09 '24 13:09 SShadowS

I found the issue: a new repo clone wasn't flagged as safe. Maybe add checks to catch that.

SShadowS avatar Sep 09 '24 14:09 SShadowS

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"?

paul-gauthier avatar Sep 09 '24 21:09 paul-gauthier

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.

SShadowS avatar Sep 09 '24 21:09 SShadowS

Any idea why git diff --cached would fail when git doesn't consider the directory safe?

paul-gauthier avatar Sep 11 '24 15:09 paul-gauthier

Any idea why git diff --cached would 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.

fry69 avatar Sep 11 '24 15:09 fry69

I can confirm that git config --global --add safe.directory F:/GitHub/my-project fixed this super annoying issue for me. Thank you!

haal-laah avatar Sep 20 '24 09:09 haal-laah

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 Sep 20 '24 19:09 paul-gauthier

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.

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>

pe-chile avatar Oct 24 '24 15:10 pe-chile