Skip to content
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 thrown when running lint-staged from a child directory #1027

Closed
jdanil opened this issue Oct 9, 2021 · 10 comments
Closed

Error thrown when running lint-staged from a child directory #1027

jdanil opened this issue Oct 9, 2021 · 10 comments

Comments

@jdanil
Copy link

jdanil commented Oct 9, 2021

Description

After upgrading to v11.2.1, lint-staged exits with the following error.

× Current directory is not a git directory!

I am using lint-staged in a monorepo, so each package runs the command (as advised here https://github.com/okonet/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo), rather than being run from the repository root directory.

Steps to reproduce

  1. run lint-staged in a child directory of the git repository's root.

Debug Logs

expand to view
{
  '*': [
    'eslint --fix',
    'prettier --write'
  ]
}

Environment

  • OS: Windows 10
  • Node.js: 14.18.0
  • lint-staged: 11.2.1
@iiroj
Copy link
Member

iiroj commented Oct 9, 2021

Hello,

does this happen with 1.12.0? If not then it's a bug introduced in PR #1026.

we might be missing a test case, so if you can get it to reproduce I'll be happy to fix it an add a test!

@tkalmar
Copy link
Contributor

tkalmar commented Oct 9, 2021

The culprit is indeed my cygwin fix. Sorry for any inconvinience.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2021

🎉 This issue has been resolved in version 11.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jdanil
Copy link
Author

jdanil commented Oct 10, 2021

Hi, thanks for the quick response! I gave 11.2.2 a try today, and I believe I'm still facing the same issue.

I did a bit more digging, and I believe the issue for me is occurring in determineGitDir. Specifically cwd.substring(0, cwd.lastIndexOf(relativeDir)). This appears to be returning an empty string.

I have a public repo you can reproduce it on https://github.com/jdanil/skunkworks. Just run yarn precommit in any non-root workspace.

@iiroj iiroj reopened this Oct 10, 2021
@iiroj
Copy link
Member

iiroj commented Oct 10, 2021

Thanks @jdanil, let me reopen the ticket.

EDIT: This seems to be a Windows-specific issue since I can't replicate it on macOS:

~/git/skunkworks/applications/app master
❯ yarn precommit
→ No staged files found.

@aleksanderfret
Copy link

I tried 11.2.2 today. And I also got "Current directory is not a git directory!" regardless of whether I ran the script in the root or in individual packages.
(Windows 10)

@iiroj
Copy link
Member

iiroj commented Oct 10, 2021

@aleksanderfret any help from Windows users is appreciated! I could also revert the changes of 11.2.1 and 11.2.2 (and release 11.2.3) until the original Cygwin issue is fixed in a new PR without breaking non-cygwin Windows environments.

What do you think, @okonet?

@tkalmar
Copy link
Contributor

tkalmar commented Oct 10, 2021

Meh tested on all (for me) available windows plattforms. Worked on cygwin, but not git-bash or git-cmd. The error has been found an corrected in #1029

@jdanil
Copy link
Author

jdanil commented Oct 10, 2021

That did the trick! Thanks @tkalmar and @iiroj 🙏

@iiroj iiroj closed this as completed Oct 11, 2021
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 11.3.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants