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.

Bug when run with husky from atom git gui

See original GitHub issue

Description

When I commit from the cli everything works fine, but when I commit from atom i get this error:

Steps to reproduce

  1. use atom
  2. setup to use lint-staged with husky
  3. try to commit from Atom git gui

Debug Logs

STDERR: 17:22:04.472031 git.c:418
trace: built-in: git rev-parse --verify HEAD
husky > pre-commit hook failed (add --no-verify to bypass)
Command failed: /bin/sh -c lint-staged

after digging around and adding logs I ended up in the staged-git-files code and I found that when it’s calling node’s child_process.spawn the PATH is not correctly set.

    var cmd = spawn(bits[0], args, {
        cwd: module.exports.cwd
    });

if I add:

    var cmd = spawn(bits[0], args, {
        cwd: module.exports.cwd,
        env: {
          PATH: process.env.PATH
        }
    });

everything start working again

Environment

  • OS: Ubuntu 18.0.4
  • Node.js: 10.15.1
  • lint-staged: 8.1.3

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
nelson6e65commented, Jun 17, 2020

I solved my problem by using npx lint-staged instead of int-staged proposed by @zorzysty in https://github.com/okonet/lint-staged/issues/420#issuecomment-558121775 :

    "hooks": {
-     "pre-commit": "lint-staged"
+     "pre-commit": "npx lint-staged"
    }
2reactions
iirojcommented, Jun 17, 2020

Glad you got it solved. I don’t this is directly an issue with lint-staged, so I’ll close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix error 'not found husky-run' when committing new ...
If you're using Husky v4 or lower, do the following: rm -rf .git/hooks npm install ... To fix this in husky version 6...
Read more >
20 Git Commands you (probably) didn't know about ‍♂️
20 Git Commands you (probably) didn't know about ‍♂️ · Git Web · Git Notes · Git Bisect · Git Grep · Git...
Read more >
Introducing a complete toolchain - Learn web development
We've come a long way in this chapter, building up a rather nice local development environment to create an application in.
Read more >
atscm - UNPKG
If you find a bug in the source code, you can help us by submitting an issue to this repository. Even better, you...
Read more >
@aesop-engineering/gel - npm
Rollup builds ES Modules for this project. The following command will also construct the Typescript declaration files. npm run build. Git ...
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