'Problem trying to install diesel (Mac air m1)

I am following the diesel guide: LINK

When i try this:

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

i receive this error:

error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at

and a Note:

 = note: ld: library not found for -lpq


Solution 1:[1]

Solution:

The problem is cargo cannot locate the pq library, so i need to use:

 sudo apt install libpq-dev

This send me a error too:

The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
Please visit http://www.java.com for information on installing Java.

First I need to check Environment Variables, check your file:

% open -e .bash_profile

File content:

export JAVA_HOME=$(/usr/libexec/java_home)

But the error continue... so then that doesnt help me. I think sometimes just need this, in my case i install the elements by one bye with brew.

Second: Install postgreql

brew install postgresql

Third:Install libpq

brew install libpq  

Finally: Install diesel CLI

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

Solution 2:[2]

Once you have install

brew install postgresql
brew install libpq

Install diesel CLI

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

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 josedlujan
Solution 2 Nenjo Tsu