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!
Thank you very much, you saved me a lot of time: I would probably not have suspected such an important batch procedure was not working before having spent a couple more hours investigating the issue.
ReplyDeleteIt worked fine for me with PostgreSQL 9.6.2-3. x64 on a Windows 10 x86_64 computer.
Glad it helped! Btw, just to clarify, do you mean the fix worked or the original file worked without the fix?
Delete1) I had to modify the currently distributed file
Delete2) I replaced the first line by:
@SET PATH=D:\Program Files\PostgreSQL\9.6\bin;%PATH%
Another variant that was suggested to me would work as well:
@SET "PATH=D:\Program Files\PostgreSQL\9.6\bin;%PATH%"
I went with the first one for consistency reasons though.