CodeCrafters CLI error running tests

I get an error when run codecrafters test:

create temp branch: add all files: fatal: not a git repository (or any of the parent directories): .git

but actually this folder is a git repository and .git exists.

ls output:

total 40
drwxr-xr-x@ 11 aurora  staff   352 Jun  6 21:23 .
drwxr-xr-x   5 aurora  staff   160 Jun  6 13:19 ..
drwxr-xr-x@  4 aurora  staff   128 Jun  6 13:19 .codecrafters
drwxr-xr-x@ 14 aurora  staff   448 Jun  7 11:45 .git
-rw-r--r--@  1 aurora  staff    12 Jun  6 13:19 .gitattributes
drwxr-xr-x@  3 aurora  staff    96 Jun  6 21:58 app
-rw-r--r--@  1 aurora  staff   281 Jun  6 21:00 codecrafters.yml
-rw-r--r--@  1 aurora  staff    62 Jun  6 13:19 go.mod
-rw-r--r--@  1 aurora  staff     0 Jun  6 13:19 go.sum
-rw-r--r--@  1 aurora  staff  1359 Jun  6 13:19 README.md
-rwxr-xr-x@  1 aurora  staff   773 Jun  6 13:19 your_program.sh

MacOS Sequoia 15.5

Thank you!

Hey @kravlad, could you share the contents of your .git directory? It might be corrupted.

It should look something like this:

Also, could you run git status and share the output?

Hi andy1li, thanks for your reply.

It doesn’t look that git directory might be corrupted. I did git clone just a day ago and did nothing except git commit and git push.

Anyway, below requested outputs:



@kravlad Would you mind zipping your repo and sending it to “hello at codecrafters.io”?

Sure, already sent from kravlad86 at gmail

I’ve received your repo, but couldn’t reproduce the error when running codecrafters test.

Could you try the following to see if it resolves the issue on your end?

  • Reinstall the CLI
brew reinstall codecrafters-io/tap/codecrafters
  • Re-clone the repo

No, nothing of those helped

Hey @kravlad, sorry for the delayed response!

For context: the CLI actually copies your repo into a temporary directory before running the Git commands from there. This error looks a bit unusual, so I made a special debug build of the CLI that logs extra info.

Could you please run it and share the output? Here’s how:

  1. Clone the repo: git clone https://github.com/codecrafters-io/cli && cd cli

  2. Checkout the debug branch: git checkout andy/debug-temp-branch

  3. Re-install the CLI: make install

Once you’ve run the same command again, could you please paste the full output? Thanks!


FYI, here’s what the extra logs look on my machine:

Hi @andy1li , here you go :slight_smile:

No CodeCrafters git remotes found. Available remotes: ``https://github.com/codecrafters-io/cli
Please run this command from within your CodeCrafters Git repository.

1 Like

@kravlad Thanks for sharing the output!

Looks like you ran codecrafters test inside the cli repo. Could you try running it from within ~/projects/edu/codecrafters/codecrafters-shell-go and sharing the output again? Thanks!

oh, :man_facepalming:

create temp branch: run git command: fatal: not a git repository (or any of the parent directories): .git
. Error: exit status 128

output is the same

@kravlad hmm, no extra logs were printed. :thinking:

Could you try deleting the existing codecrafters binary, reinstall the debug build from the andy/debug-temp-branch branch, and then run codecrafters test again inside your challenge repo? Thanks!

yeah, it worked out.

⛳ localGitIgnore path: /Users/aurora/projects/edu/codecrafters/codecrafters-shell-go/.gitignore
⛳ localGitIgnore content:

Created by https://www.gitignore.io

Go

If you prefer the allow list template instead of the deny list, see community template:








Binaries for programs and plugins

*.exe
*.exe~
*.dll
*.so
*.dylib

Test binary, built with go test -c

*.test

Output of the go coverage tool, specifically when used with LiteIDE

*.out

Dependency directories (remove the comment below to include it)

vendor/

Go workspace file

go.work

.pre-commit-config.yaml

⛳ globalGitIgnore path: /Users/aurora/configs/gitignore
⛳ globalGitIgnore content:
.git
*.git

_t.

*t.

t_.

tmp/
*tmp/
tmp*/

.history/
tasks.md
.side/
.DS_Store
⛳ gitInfoExclude path: /Users/aurora/projects/edu/codecrafters/codecrafters-shell-go/.git/info/exclude
⛳ gitInfoExclude content:

git ls-files --others --exclude-from=.git/info/exclude

Lines that start with ‘#’ are comments.

For a project mostly in C, the following would be a good set of

exclude patterns (uncomment them if you want to use them):

*.[oa]

*~

⛳ before copy:
⛳ ls -la  /var/folders/5b/kdgjkkvs0ml237190ytvlcq40000gn/T/codecrafters4081131857 : total 0
drwx------@    2 aurora  staff     64 Jan 13 16:54 .
drwx------@ 1770 aurora  staff  56640 Jan 13 16:54 ..

⛳ after copy:
⛳ ls -la  /var/folders/5b/kdgjkkvs0ml237190ytvlcq40000gn/T/codecrafters4081131857 : total 1328
drwxr-xr-x@   20 aurora  staff     640 Jan 13 16:54 .
drwx------@ 1770 aurora  staff   56640 Jan 13 16:54 ..
drwxr-xr-x@    4 aurora  staff     128 Jan 13 16:54 .codecrafters
-rw-r–r–@    1 aurora  staff      12 Jan 13 16:54 .gitattributes
-rw-r–r–@    1 aurora  staff     556 Jan 13 16:54 .gitignore
drwxr-xr-x@    3 aurora  staff      96 Jan 13 16:54 .vscode
drwxr-xr-x@    3 aurora  staff      96 Jan 13 16:54 app
-rw-r–r–@    1 aurora  staff     281 Jan 13 16:54 codecrafters.yml
-rw-r–r–@    1 aurora  staff      62 Jan 13 16:54 go.mod
-rw-r–r–@    1 aurora  staff       0 Jan 13 16:54 go.sum
-rw-r–r–@    1 aurora  staff    1359 Jan 13 16:54 README.md
-rwxr-xr-x@    1 aurora  staff     773 Jan 13 16:54 your_program.sh

create temp branch: run git command: fatal: not a git repository (or any of the parent directories): .git
. Error: exit status 128
1 Like

@kravlad Ah, the issue was caused by this:

⛳ globalGitIgnore path: /Users/aurora/configs/gitignore
⛳ globalGitIgnore content:
.git
*.git

Those patterns are a bit unusual since Git treats .git/ specially, and it ends up interfering with our CLI, which relies on the .git/ directory being present to interact with the repository correctly.

Removing these lines from your global gitignore should resolve the issue. Let me know how it goes!

yes, it’s finally working. No idea how I got those patterns there :slight_smile: Thank you so much for helping!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.