Search code examples
rustrust-cargorust-diesel

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

  • 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