When attempting to run osm2pgsql in command prompt, I ran into the password prompt as described here. This requires installing a patch. I'm unfamiliar on how to install a .diff patch on Windows 7.

Do I need to install GnuWin as shown here?

Thanks for all the help!

EDIT: This is the same question as this one on Stack Overflow.


I ran into the same problem recently and you don't need to apply a patch (especially as the patch is now older than the latest release by about 4 years!). The new binary version simply does not allow the -W switch (at least not in Windows) and you will get the error message:

illegal option: -- W

However, the -h help documentation is misleading because it implies you canuse the -W option (and in previous versions you needed to). However, the clue is in the documentation for the -U switch. All you need to do before running osm2pgsql is temporarily set a PGPASS environment variable by typing at the command prompt:

set PGPASS=mypassword

Then run osm2pgsql as normal, specifying the username with -U but, of course, omitting -W.

  • That did the trick! I edited my original post to include a link from a recent Stack Overflow post with the same question and comment. Thanks for the help! – Zach May 7 '13 at 21:26

I'd suggest not applying such a change, for the reasons given in the patch response that you linked to. A safer alternative might be to hard-code your password into the script, then protect the script.

However if you understand the consequences of making the change, including potential security issues, then you could hand-apply the change against a current version of the osm2pgsql script.

Essentially, its just going to be a matter of finding the old text, and making it look like the text in the diff. There have almost certainly been some changes in the original - just adapt the patch to fit. Then rebuild osm2pgsql.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.