cargopostgresql95% confidence\u2191 26

How to fix diesel_cli link libpq.lib error with Postgres tools installed in Docker?

Full error message
I'm trying (for hours now) to install the cargo crate diesel_cli for postgres. However, every time I run the recommended cargo command:

cargo install diesel_cli --no-default-features --features postgres

I wait a few minutes just to see the same build fail with this message:

note: LINK : fatal error LNK1181: cannot open input file 'libpq.lib'

error: aborting due to previous error
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `C:\Users\<user name here>\AppData\Local\Temp\cargo-installUU2DtT`

Caused by:
  could not compile `diesel_cli`.

I'm running postgres in a docker container and have the binaries on my C:\pgsql with the lib and bin directories both on the PATH so I can't figure out why it's not linking. What else could be required they didn't mention in the docs?

Update: The answer below is a work around for older versions. Please check the possibility to execute cargo clean first Original Version Adding the folder to the PATH variable didn't help, at least in my case, as by some reason it is not used in the /LIBPATH parameter passed to link.exe. In my case it was C:\Users\<username>\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib You can see it in the beginning of the error message. Copy libpq.lib in there and it will be used from there. After installation diesel would require some other assemblies. Copy libcrypto-1_1-x64.dll, libiconv-2.dll and libssl-1_1-x64.dll into the folder showed after where diesel command execution

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/b9a8a02f81fdc7942f61f81d5b36b24871f1c0b91f0e6246b20490f991526abd
hash \u00b7 b9a8a02f81fdc7942f61f81d5b36b24871f1c0b91f0e6246b20490f991526abd
How to fix diesel_cli link libpq.lib error with Postgres too… — DepScope fix | DepScope