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

v5 stdin is not a tty #850

Closed
jdanil opened this issue Feb 4, 2021 · 7 comments
Closed

v5 stdin is not a tty #850

jdanil opened this issue Feb 4, 2021 · 7 comments

Comments

@jdanil
Copy link

jdanil commented Feb 4, 2021

The pre-push command seems to be failing with stdin is not a tty after migration to v5. This looks like a similar issue to #627.

The error seems to occur in other shell environments as well, even when winpty isn't present.

Versions

  • OS: Windows 10
  • Git: 2.29.0.windows.1
  • Shell: Git Bash
  • Node: 14.15.4
  • Package Manager: Yarn 2.4.0

An example to reproduce the error can be found here.

@typicode
Copy link
Owner

typicode commented Feb 4, 2021

Hi @jdanil,

FWIW right now trying on Linux (I'll try on Windows later) and can't reproduce:

$ git push
lerna notice cli v3.22.1
lerna info versioning independent
lerna notice filter changed since "master"
lerna info Looking for changed packages since master
lerna info Executing command in 1 package: "yarn run compile"
lerna success run Ran npm script 'compile' in 1 package in 3.9s:
lerna success - @application/app
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 541 bytes | 541.00 KiB/s, done.
Total 7 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:typicode/skunkworks
   38b1490..0f2274e  chore/husky-5 -> chore/husky-5

@typicode
Copy link
Owner

typicode commented Feb 4, 2021

Could you try running yarn husky install again and do a push?

@jdanil
Copy link
Author

jdanil commented Feb 5, 2021

Hi @typicode. Thanks for looking into this.

I tried it on macOS too btw, and didn't have any issues there.

I ran yarn husky install again and tried another push, but still had the same issue. The re-install didn't cause any file changes btw (just removed some extra whitespace from the .husky/.gitignore file).

Let me know if I can provide any extra debugging information or test out changes if you don't have a Windows environment handy.

I tried running with the HUSKY_DEBUG environment variable, and it didn't really have any extra information.

$ HUSKY_DEBUG=1 git push origin chore/husky-5
husky (debug) - starting pre-push...
stdin is not a tty
husky - pre-push hook exited with code 1 (error)
error: failed to push some refs to 'https://github.com/jdanil/skunkworks.git'

@typicode
Copy link
Owner

typicode commented Feb 5, 2021

I remember this issue. I think it's related to yarnpkg/yarn#2998

Here's a workaround for husky 5 + Yarn on Windows, create .husky/common.sh:

command_exists () {
  command -v "$1" >/dev/null 2>&1
}

# Windows 10, Git Bash and Yarn workaround
if command_exists winpty && test -t 1; then
  exec < /dev/tty
fi

Source it in commit-msg, pre-commit and pre-push:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

yarn ...

It doesn't seem to be necessary in places where just yarn install is executed.

I'll update docs.

@jdanil
Copy link
Author

jdanil commented Feb 6, 2021

Can confirm that unblocked the pre-push hook. Thanks @typicode!

If anyone is looking this up later, since the above branch has been deleted after merge, here is the pr for husky 5 migration for this yarn repo jdanil/skunkworks#1398.

@adrianwix
Copy link

Same error in "husky": "^6.0.0" using yarn

PS C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp> git push
stdin is not a tty
husky - pre-push hook exited with code 1 (error)
error: failed to push some refs to 'gitlab.com:posterlab/posterlab-mvp.git'

pre-push

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

cd nest-backend 
yarn test /comments
yarn build

@orimdominic
Copy link

orimdominic commented Jun 30, 2021

A teammate of mine is having this exact issue too, even after applying the workaround for husky 5 + Yarn on Windows fix

Same error in "husky": "^6.0.0" using yarn

PS C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp> git push
stdin is not a tty
husky - pre-push hook exited with code 1 (error)
error: failed to push some refs to 'gitlab.com:posterlab/posterlab-mvp.git'

pre-push

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

cd nest-backend 
yarn test /comments
yarn build

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

No branches or pull requests

4 participants