Search code examples
windows-10stdinpsqlgit-bashtty

In Git Bash, how do I fix a "stdin is not a tty" error?


I'm using Git Bash on Windows 10. I would like to import a SQL file to be run in my PostGres 12 local database. I tried the below

$ PGPASSWORD=$DB_PASSWORD psql -U${DB_USER} $DB_NAME < scripts/my-script.sql
stdin is not a tty

When I look in my database, the script hasn't been run, which leads me to believe the error message is telling me why, except I'm not sure what it means or how to fix it.


Solution

  • Don't use redirection on Windows (in general, not just in "git-bash").

    Pass the script file using the -f parameter:

    PGPASSWORD=$DB_PASSWORD psql -U${DB_USER} -f scripts/my-script.sql $DB_NAME