husky: [4.0.0 | Git Bash | Windows 10] stdin is not a tty
Husky 4.0.0 isn’t working in Git Bash for Windows 10, triggering a stdin is not a tty
error for every git operation that triggers a hook.
Versions
OS: Windows 10 1903
Shell: Git Bash (GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
)
Git: git 2.24.1.windows.2
HUSKY_DEBUG=1 npm install husky --save-dev
$ HUSKY_DEBUG=1 npm install husky --save-dev
> husky@4.0.0 install C:\dev\test\husky4-tty-test\node_modules\husky
> node husky install
husky > Setting up git hooks
husky:debug Current working directory is C:\dev\test\husky4-tty-test\node_modules\husky
husky:debug INIT_CWD is set to C:\dev\test\husky4-tty-test
husky:debug Git rev-parse command returned:
husky:debug --git-common-dir: undefined
husky:debug --show-prefix:
The "path" argument must be of type string. Received type undefined
husky:debug TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:112:11)
at Object.resolve (path.js:139:9)
at getDirs (C:\dev\test\husky4-tty-test\node_modules\husky\lib\installer\bin.js:27:49)
at run (C:\dev\test\husky4-tty-test\node_modules\husky\lib\installer\bin.js:62:62)
at Object.<anonymous> (C:\dev\test\husky4-tty-test\node_modules\husky\lib\installer\bin.js:85:1)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
husky > Failed to install
> husky@4.0.0 postinstall C:\dev\test\husky4-tty-test\node_modules\husky
> opencollective-postinstall || exit 0
Thank you for using husky!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/husky/donate
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN husky4-tty-test@1.0.0 No description
npm WARN husky4-tty-test@1.0.0 No repository field.
+ husky@4.0.0
added 48 packages from 22 contributors and audited 48 packages in 2.047s
3 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
HUSKY_DEBUG=1 git commit
Note: on the fresh test repo, this command worked because the first command failed so the hooks did not install properly. On an existing repo with existing hooks, it looks like this:
husky:debug husky v4.0.0 (created at 1/7/2020, 1:24:18 PM)
husky:debug pre-commit hook started
husky:debug Current working directory is /c/dev/test/existing-repo
husky:debug pre-commit hook started
stdin is not a tty
husky:debug yarn husky-run exited with 1 exit code
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 42 (18 by maintainers)
Commits related to this issue
- build: update husky Husky was failing on push due to https://github.com/typicode/husky/issues/627. — committed to filipesilva/angular-cli by filipesilva 4 years ago
- build: update husky Husky was failing on push due to https://github.com/typicode/husky/issues/627. — committed to filipesilva/angular-cli by filipesilva 4 years ago
- build: update husky Husky was failing on push due to https://github.com/typicode/husky/issues/627. — committed to angular/angular-cli by filipesilva 4 years ago
- build: update husky Husky was failing on push due to https://github.com/typicode/husky/issues/627. (cherry picked from commit 3eaa881a4390d19fe2f2539405d153e4a939979c) — committed to dgp1130/angular-cli by filipesilva 4 years ago
- build: update husky Husky was failing on push due to https://github.com/typicode/husky/issues/627. (cherry picked from commit 3eaa881a4390d19fe2f2539405d153e4a939979c) — committed to angular/angular-cli by filipesilva 4 years ago
ok, this does the trick:
If I run
npx husky
then the git commands are working again. It’s of course a workaround.Windows 11, bash. step1: cd ~ step2: $ touch .huskyrc step3: nano .huskyrc step4: paste
step5: ctrl+x to save Success!!
thx
viceice
, it worked smoothly in windows 10I too saw this on
git push
from a Windows 10 machine using Git v2.20.1.windows.1 and Yarn v1.21.1. Downgrading to3.1.0
fixed the issue.Found it, installed Yarn using the Windows installer (https://yarnpkg.com/en/docs/install#windows-stable) and it fails with
stdin is not a tty
🎉Adding
exec < /dev/tty
to~/.huskyrc
as mentioned in several other similar issues gets around the problem but I didn’t see anything about it in the change log and suspect it shouldn’t be required based on those other discussions.I think the problem was fixed already a longer time ago. Just update to the latest 4* version.
I installed
git
,nodejs-lts
andyarn
with chocolatey.git: 2.24.1.windows.2 yarn: 1.21.1 node: 12.14.1
Tested and validated #634 feel free to review it 😃
after enough investigating it seems to me that this is bug located inside the
yarn
v1’s shell script using winptyI created two PRs, first one solve winpty problem if you still wish to use
yarn run
and second one usesnpx
instead ofyarn run
should be noted that the first one is dependent on which version of yarn your using. So it might need some additional logic
for me v4.0.4 still fails and seems to be related to yarn v1.21.1 if I go into
pre-push
hook shell script and changepackageManager=yarn
topackageManager=npm
it I can suddenlygit push
again.Seeing this on
git push
tooRoleback to 3.1.0 as workaround
Seems it’s related to eslint in my case:
Seems like you should limit what get’s published in your npm package.