"the input device is not a TTY" error on git commit in WSL

251 Views Asked by At

I am setting up a new development environment which, on the surface, is the same as the environment I have on another computer:

  • Windows 10
  • WSL running AmazonLinux2
  • Windows terminal
  • git version 2.40.1

Using the terminal, I've staged a new set of changes, then type:

git commit -S -m "My commit message here"

Which returns this mmessage:

the input device is not a TTY

Checking git status shows that the staged changes remain uncommitted.

I've tried:

  • Removing -m and the message, hoping git will open vim
  • Removing the -S switch
  • Running --dry-run
  • All permutations of the above
  • Configuring git's core.terminal setting to vi (which I believe is default, but hey, you never know)

When I Google the message, almost all of the results relate to Docker shells, and seem unrelated (most of the answers involve removing or altering the -it switches from a docker exec command). I do have Docker running, but the git command is not being run in a Docker instance.

Again, I do not have this issue on another computer with seemingly the same setup.

Update

I figured out the cause, and have found a way to work around it without actually solving it; see my own answer below.

Again, not a solution, as linting is there for a reason, obviously, but I was able to push up my changes, complete the task, and push off dealing with the error for another day. The question is still open.

2

There are 2 best solutions below

2
colin On

This is not a solution to the cause of the error, but a workaround that allowed me to continue working.

git is configured on my machine with a preprocessor that runs GrumPHP to lint my code; the TTY error is being thrown by GrumPHP. I was able to disable it in order to make my commit, but the problem with GrumPHP remains.

For anyone with a similar problem who Googled your way here, if you have preprocessing configured in your commit flow, the scripts will be in the .git/hooks/ folder of your project. In my case, I edited .git/hooks/pre-commit and /.git/hooks/commit-msg and simply commented out the GrumPHP scripts.

0
Erwane On

GrumpPHP has option for this case : In the grumphp.yml config file in your project.

grumphp:
  git_hook_variables:
    EXEC_GRUMPHP_COMMAND: docker compose exec --no-TTY your-container-name
    ENV: {
      PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:./bin:./vendor/bin"
    }

Even if you don't do your "git commit" in the docker, grumphp need php environment and should be executed in your docker.