question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

8.0.0 monorepo not a git repository: '.git'

See original GitHub issue

Description

8.0.0 seems to be broken with monorepos. Getting this output

lerna info version 2.5.1
say-bye: Stashing changes... [started]
say-bye: Stashing changes... [failed]
say-bye: → fatal: not a git repository: '.git'
say-bye: fatal: not a git repository: '.git'

with the example monorepo https://github.com/sudo-suhas/lint-staged-multi-pkg

Steps to reproduce

  1. Clone down https://github.com/sudo-suhas/lint-staged-multi-pkg
  2. Update the packages to use lint-staged: ^8.0.0
  3. Run yarn or npm install
  4. Run npx lerna bootstrap
  5. Edit a .js file inside of a package
  6. Try to commit the change

Debug Logs

expand to view
lerna info version 2.5.1
say-bye: 2018-10-29T18:30:20.810Z lint-staged:bin Running `lint-staged@8.0.0`
say-bye: 2018-10-29T18:30:20.993Z lint-staged:find-bin Loaded package.json using `process.cwd()`
say-bye: 2018-10-29T18:30:21.093Z lint-staged Loading config using `cosmiconfig`
say-bye: 2018-10-29T18:30:21.106Z lint-staged Successfully loaded config from `/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/packages/say-bye/.lintstagedrc.yml`:
say-bye: { linters: { 'lib/*.js': [ 'eslint --fix', 'git add' ] } }
say-bye: 2018-10-29T18:30:21.106Z lint-staged:cfg Normalizing config
say-bye: Running lint-staged with the following config:
say-bye: {
say-bye:   linters: {
say-bye:     'lib/*.js': [
say-bye:       'eslint --fix',
say-bye:       'git add'
say-bye:     ]
say-bye:   },
say-bye:   concurrent: true,
say-bye:   chunkSize: 9007199254740991,
say-bye:   globOptions: {
say-bye:     matchBase: true,
say-bye:     dot: true
say-bye:   },
say-bye:   ignore: [],
say-bye:   subTaskConcurrency: 1,
say-bye:   renderer: 'verbose'
say-bye: }
say-bye: 2018-10-29T18:30:21.108Z lint-staged:cfg Validating config
say-bye: 2018-10-29T18:30:21.111Z lint-staged:run Running all linter scripts
say-bye: 2018-10-29T18:30:21.112Z lint-staged:run Resolved git directory to be `/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/`
say-bye: 2018-10-29T18:30:21.130Z lint-staged:run Loaded list of staged files in git:
say-bye: [ 'packages/say-hi/src/index.js',\n  'packages/say-hi/package.json',\n  'packages/say-hi/package-lock.json',\n  'packages/say-bye/package.json',\n  'packages/say-bye/package-lock.json' ]
say-bye: 2018-10-29T18:30:21.130Z lint-staged:gen-tasks Generating linter tasks
say-bye: 2018-10-29T18:30:21.130Z lint-staged:cfg Normalizing config
say-bye: 2018-10-29T18:30:21.139Z lint-staged:gen-tasks Generated task:
say-bye: Stashing changes... [started]
say-bye: { pattern: 'lib/*.js',\n  commands: [ 'eslint --fix', 'git add' ],\n  fileList: [] }
say-bye: Stashing changes... [failed]
say-bye: → fatal: not a git repository: '.git'
say-bye: fatal: not a git repository: '.git'
say-bye:
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: npm run precommit
lerna ERR! 2018-10-29T18:30:20.810Z lint-staged:bin Running `lint-staged@8.0.0`
lerna ERR! 2018-10-29T18:30:20.993Z lint-staged:find-bin Loaded package.json using `process.cwd()`
lerna ERR! 2018-10-29T18:30:21.093Z lint-staged Loading config using `cosmiconfig`
lerna ERR! 2018-10-29T18:30:21.106Z lint-staged Successfully loaded config from `/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/packages/say-bye/.lintstagedrc.yml`:
lerna ERR! { linters: { 'lib/*.js': [ 'eslint --fix', 'git add' ] } }
lerna ERR! 2018-10-29T18:30:21.106Z lint-staged:cfg Normalizing config
lerna ERR! 2018-10-29T18:30:21.108Z lint-staged:cfg Validating config
lerna ERR! 2018-10-29T18:30:21.111Z lint-staged:run Running all linter scripts
lerna ERR! 2018-10-29T18:30:21.112Z lint-staged:run Resolved git directory to be `/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/`
lerna ERR! 2018-10-29T18:30:21.130Z lint-staged:run Loaded list of staged files in git:
lerna ERR! [ 'packages/say-hi/src/index.js',
lerna ERR!   'packages/say-hi/package.json',
lerna ERR!   'packages/say-hi/package-lock.json',
lerna ERR!   'packages/say-bye/package.json',
lerna ERR!   'packages/say-bye/package-lock.json' ]
lerna ERR! 2018-10-29T18:30:21.130Z lint-staged:gen-tasks Generating linter tasks
lerna ERR! 2018-10-29T18:30:21.130Z lint-staged:cfg Normalizing config
lerna ERR! 2018-10-29T18:30:21.139Z lint-staged:gen-tasks Generated task:
lerna ERR! { pattern: 'lib/*.js',
lerna ERR!   commands: [ 'eslint --fix', 'git add' ],
lerna ERR!   fileList: [] }
lerna ERR! fatal: not a git repository: '.git'
lerna ERR!
lerna ERR!
lerna ERR! Running lint-staged with the following config:
lerna ERR! {
lerna ERR!   linters: {
lerna ERR!     'lib/*.js': [
lerna ERR!       'eslint --fix',
lerna ERR!       'git add'
lerna ERR!     ]
lerna ERR!   },
lerna ERR!   concurrent: true,
lerna ERR!   chunkSize: 9007199254740991,
lerna ERR!   globOptions: {
lerna ERR!     matchBase: true,
lerna ERR!     dot: true
lerna ERR!   },
lerna ERR!   ignore: [],
lerna ERR!   subTaskConcurrency: 1,
lerna ERR!   renderer: 'verbose'
lerna ERR! }
lerna ERR! Stashing changes... [started]
lerna ERR! Stashing changes... [failed]
lerna ERR! → fatal: not a git repository: '.git'
lerna ERR!
lerna ERR!
lerna ERR!     at Promise.all.then.arr (/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/node_modules/execa/index.js:236:11)
(node:36142) UnhandledPromiseRejectionWarning: Error: Command failed: npm run precommit
2018-10-29T18:30:20.810Z lint-staged:bin Running `lint-staged@8.0.0`
2018-10-29T18:30:20.993Z lint-staged:find-bin Loaded package.json using `process.cwd()`
2018-10-29T18:30:21.093Z lint-staged Loading config using `cosmiconfig`
2018-10-29T18:30:21.106Z lint-staged Successfully loaded config from `/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/packages/say-bye/.lintstagedrc.yml`:
{ linters: { 'lib/*.js': [ 'eslint --fix', 'git add' ] } }
2018-10-29T18:30:21.106Z lint-staged:cfg Normalizing config
2018-10-29T18:30:21.108Z lint-staged:cfg Validating config
2018-10-29T18:30:21.111Z lint-staged:run Running all linter scripts
2018-10-29T18:30:21.112Z lint-staged:run Resolved git directory to be `/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/`
2018-10-29T18:30:21.130Z lint-staged:run Loaded list of staged files in git:
[ 'packages/say-hi/src/index.js',
  'packages/say-hi/package.json',
  'packages/say-hi/package-lock.json',
  'packages/say-bye/package.json',
  'packages/say-bye/package-lock.json' ]
2018-10-29T18:30:21.130Z lint-staged:gen-tasks Generating linter tasks
2018-10-29T18:30:21.130Z lint-staged:cfg Normalizing config
2018-10-29T18:30:21.139Z lint-staged:gen-tasks Generated task:
{ pattern: 'lib/*.js',
  commands: [ 'eslint --fix', 'git add' ],
  fileList: [] }
fatal: not a git repository: '.git'


Running lint-staged with the following config:
{
  linters: {
    'lib/*.js': [
      'eslint --fix',
      'git add'
    ]
  },
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  ignore: [],
  subTaskConcurrency: 1,
  renderer: 'verbose'
}
Stashing changes... [started]
Stashing changes... [failed]
→ fatal: not a git repository: '.git'


    at Promise.all.then.arr (/Users/farismustafa/Documents/Projects/lint-staged-multi-pkg/node_modules/execa/index.js:236:11)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:36142) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:36142) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

husky > pre-commit hook failed (add --no-verify to bypass)

Environment

  • OS: macOS High Sierra
  • Node.js: v10.9.0
  • lint-staged: v8.0.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
okonetcommented, Oct 29, 2018

I can look at it tomorrow

0reactions
p4blochcommented, Nov 1, 2018

Thank you for the quick fix! ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git error - Fatal: Not a git repository and how to fix it | Datree.io
This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right...
Read more >
Not a git repository" when attempting to remote add a Git repo
You'll get this error if you try to use a Git command when your current working directory is not within a Git repository....
Read more >
Solving “Fatal: Not A Git Repository” (Or Any Of The Parent ...
In this article, we will explore what causes, how to prevent, and how to solve the “fatal: not a git repository” error.
Read more >
From a Single Repo, to Multi-Repos, to Monorepo, to Multi ...
It creates a project composed of multiple repos and doing git commit -m "some message" on the project executes a git commit -m...
Read more >
Bring your monorepo down to size with sparse-checkout
Does your repository have so many files at root that your source directory is growing out of control? Do commands like git checkout...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found