Hello.
On MacOS 12.6.1 with M1 chip, git >=2.37.0 (installed by homebrew) and
pre-commit hook that is calling *make* target, that is calling *docker
compose run* command, we get error:
the input device is not a TTY
All works file with homebrew git version 2.36.1
* DETAILS OF PROBLEM *
There is pre-commit hook in place that is using bash script to call
`make` command which is in turn calling `docker compose run` to run some
check before commit. After upgrading git version from `2.36.1` to
`>=2.37` we constantly get error:
> the input device is not a TTY
Example pre-commit hook output:
> docker compose run --rm --entrypoint "" app /code/test.sh
> the input device is not a TTY
> make: *** [Makefile:6: check] Error 1
> !!! FAILING REGARDLESS OF CHECK RESULT !!!
(the latest error message is just so we don't actually commit anything)
AFAIK `docker compose` command is auto-detecting TTY because no `-t` or
`-T` were set.
By doing some tests we managed to check that it is a problem with `git`
version.
Latest version that it worked was `2.36.1`:
> docker compose run --rm --entrypoint "" app /code/test.sh
> =================== CHECK OK =================
> !!! FAILING REGARDLESS OF CHECK RESULT !!!
Machine and software we were testing on:
> make --version
> GNU Make 3.81
>
> docker compose version
> Docker Compose version v2.12.2
>
> git --version
> git version 2.38.1
>
> which git
> /opt/homebrew/bin/git
Also, we tested with linux Ubuntu and all git versions are working fine
with same pre-commit hook. It seems related to `macOS` and `git` only.
* REPLICATING THIS PROBLEM *
Easiest way top replicate is to just clone sample repo I prepared here:
https://github.com/piotrekkr/git-tty-issue-macos
and go with replicate instructions from README.md.
If this is not okay then below I will copy and paste instruction with
file contents.
* FILES *
* Makefile *
COMPOSE_RUN = docker compose run --rm --entrypoint ""
check:
$(COMPOSE_RUN) app /code/test.sh
* docker-compose.yml *
version: "3.7"
services:
app:
image: php:8.1.3-fpm-bullseye
volumes:
- "${PWD}:/code"
working_dir: /code
* .git/hooks/pre-commit *
#!/usr/bin/env bash
make check
echo "!!! FAILING REGARDLESS OF CHECK RESULT !!!"
exit 1
* test.sh *
#!/usr/bin/env bash
echo "=================== CHECK OK ================="
(sorry for attaching like that, I'm not good with those plain text mail
lists)
* INSTRUCTIONS *
1. have macOS with M1 chip (can be expensive)
2. install `docker`, `docker compose v2`, `make`
3. upgrade git with homebrew to version `>=2.37.0`
4. clone repo or manually create files (in same directory)
- Makefile
- docker-compose.yml
- .git/hooks/pre-commit (with execute permissions)
- test.sh
5. if using repo, copy pre commit script to `.git/hooks` directory
cp pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
6. Try to commit and you should get TTY error
7. Switch git to `2.36.1` version (seems to be only possible by `brew
extract`)
brew tap-new --no-git $USER/local-tap
brew extract --version=2.36.1 git $USER/local-tap
brew install git@2.36.1
brew link --overwrite git@2.36.1
8. Try committing again, TTY problem should be fixed
Let me know if you need more details etc.
Regards
Piotrek