'Install Diesel error (3 errors) - failed to compile 'diesel_cli v1.4.1'

I'm trying to install database migration utility on my machine and run into multiple errors when trying to run in Powershell.

  • Postgres 13 running
  • I've installed Rust successfully
  • I have Postgres running in Docker as well.

But I'm still stuck and can't figure out what to do next, any help is greatly appreciated!!

Here is the command I'm running and the error messages that follow in Powershell:

PS C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools> cargo install diesel_cli --no-default-features --features postgres
    Updating crates.io index
  Installing diesel_cli v1.4.1
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.27
   Compiling unicode-xid v0.2.2
   Compiling cfg-if v1.0.0
   Compiling winapi v0.3.9
   Compiling syn v1.0.73
error: linking with `link.exe` failed: exit code: 1120
  |
  
error: aborting due to previous error

error: linking with `link.exe` failed: exit code: 1120
  |
  
error: aborting due to previous error

error: could not compile `proc-macro2`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: linking with `link.exe` failed: exit code: 1120

error: aborting due to previous error

error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `C:\Users\Owner\AppData\Local\Temp\cargo-install3Wpga4`

Caused by:
  build failed
PS C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools> setx PQ_LIB_DIR "C:\Program Files\PostgreSQL\13\lib"

SUCCESS: Specified value was saved.
PS C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools> `cargo install diesel_cli --no-default-features --features postgres`
    Updating crates.io index
  Installing diesel_cli v1.4.1
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `C:\Users\Owner\AppData\Local\Temp\cargo-installkewOEe`

Caused by:
  Package `diesel_cli v1.4.1` does not have the feature `postgres``


Solution 1:[1]

Please confirm that you install
sudo apt install libpq-dev

For more help:
https://github.com/diesel-rs/diesel/issues/2026
https://github.com/diesel-rs/diesel/issues/2465

Solution 2:[2]

Maybe If you download this solves your problem

https://www.postgresql.org/download/windows/

Solution 3:[3]

It's works for me!

sudo apt install libpq-dev

Solution 4:[4]

On windows, after installation of postgresql define environment variable which points to client libs. PQ_LIB_DIR=C:\Program Files\PostgreSQL\13\lib

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GrvTyagi
Solution 2 Samuel Durante
Solution 3 ralvescosta
Solution 4 Jovo Skorupan