Pages

Monday, February 27, 2017

Setting PostgreSQL Environment Variables on Windows (pg_env.bat)?

I needed to have postgres commands available in the command line, and found this script called pg_env.bat when I was trying to add the bin directory into my PATH environment variables. Running it from the command line does not produce any error message, and the postgres commands work fine too, however when I was running a make script it throws an error like this (truncated, I lost the actual, full error message): Error [WinError 2] The system cannot find the file specified while executing command git config --get-regexp remote\..*\.url
Turns out the answer is that I need to edit the bat script and remove the quotation marks on the line where it is adding it to PATH (@SET PATH="...";%PATH%). Remove both of the " quotation marks and it should work.
Turned out it was reported 5 years ago and for some reason they have not acted on it. I hope they fix it soon.
Something interesting to know, I found another thread that requested them to do the exact opposite, so I do not know which one supposed to be correct, but in any case, without quotes " works in my case.
Hopefully this helps anyone else facing the same issue!