New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error:Current directory is not a git directory! #627
Comments
@iiroj could you please check it out? |
I got the same problem with 8.2.0 on Linux Ubuntu 18.04, node 10.15.3. |
This is probably related to the change I made where the the git directory is determined by running If it's not working, I’d assume Can you debug this by running something like Unfortunately I’m not available to work on a fix until next week. |
@iiroj execa error。 I do not know why, cwd and command is true, but execa will throw error. |
Can you edit your husky’s You could also edit One other debug is to print out EDIT: if you run EDIT2: this might be related: DonJayamanne/gitHistoryVSCode#233 (comment) |
@iiroj I used your note about DonJayamanne/gitHistoryVSCode#233 (comment) to implement a potential fix. I've added a test case and tested it locally and it all seems to work. I hope I'm not being too presumptuous by opening the PR ;-> PR reference - #628 |
@carnun did you test that |
@iiroj I added a console.log to resolveGitDir and checked what happened when I do
a git commit from the command line to trigger lint-staged. In this case I
see that process.env.GIT_DIR is set and then lint staged fails. Also note
that GIT_DIR is definitely not set in my console, so it must be the "git
commit" that sets the environment variable. If I run lint-staged from the
command line directly then this bug doesn't surface.
What actually happens is that the `execa` command fails since `GIT_DIR` is set to the wrong value. Hope this makes sense.
Not really sure how to encapsulate all of this in a unit test...
|
@iiroj the only improvement I can think to add to my PR is to restore process.env.GIT_DIR after resolving the git root dir. I'm just not sure whether that may cause any other issues. |
@carnun execa supports an option Would setting this to |
@iiroj I'll quickly try that and see if it resolves the issue |
@iiroj what you actually need to do is pass in |
That would be cleaner than mutating |
@iiroj yeah, I am experiencing this on an actual project - I use lint-staged along with To debug it I just hacked I see your CI/CD also checks node 8/9 which I haven't checked... |
@iiroj for some reason my updated PR fails on node 8 and 9. This works for node10, but fails on node8 and node9 - #628
This works on node8, node9 and node10 - #629
|
Updating git to latest version (2.21.0) resolve issue |
🎉 This issue has been resolved in version 8.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
btw, I get the same with:
|
@tripodsan that's a pretty old git version! Can you try updating it and see if that itself helps? |
it's running in a CI system....but after updating the image to a more recent version it passed:
|
I experience this issue with recent
Note that I'm using Gentoo and I'm sure that I have some outdated packages, but git and the currently available lint-staged is not one of them Edit: |
After further investigations, I found out that only the following versions fail:
10.0.0 and 10.0.5 works fine Running |
what if i'm using cygwin? $ git rev-parse --show-toplevel
/cygdrive/c/workSpace/my-project
> process.cwd()
'C:\\workSpace\\my-project' it won't match as |
figured it out..... |
Seeing this issue with
|
I keep hitting the issue[1], upgrading lint-staged seems to have helped. [1] lint-staged/lint-staged#627
I am getting this error currently in a project using bun, but only on Linux, not on MacOS. Linux setup: MacOS setup: On Mac, the checks work correctly. On Linux, I get The project is in a subdirectory of another repo, so if repo base is |
@mrdomino Bun must do something different than Node.js... I can't say lint-staged supports Bun because I haven't ever tested it. Can you first try upgrading Git to the latest version? |
Ah, never mind, I found the culprit. I had a complicated git setup and long story short, I did a |
Description
There is an error in v8.2.0,Current directory is not a git directory!
Steps to reproduce
I have this problem when I installed the new version of lint-staged. I think it may be because my .git is in the upper level of the installation directory.
install path:/web-front/src-new/node_modules/lint-staged
.git path: /web-front/.git
Debug Logs
Environment
lint-staged
: v8.2.0Ps
This should be because you changed the way get the .git directory in the new version.
husky issue: typicode/husky#500
your commit: 6ac666d
The text was updated successfully, but these errors were encountered: