postgresql 11 and 12 are both installed but postgresql --version says no such command

I wanted postgresql 11 but installed it the wrong way first (possibly using curl) and then installed 12 with apt-get and then installed 11. I have both 11 and 12 directories in etc/postgresql with all the needed files.

Here is the Diesel error I get:

$ cargo install diesel_cli --no-default-features --features postgres
Updating crates.io index
Installing diesel_cli v1.4.0
Compiling libc v0.2.65
Compiling proc-macro2 v1.0.6
...
Compiling toml v0.4.10
Compiling diesel_cli v1.4.0
error: linking with cc failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.0.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.1.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.10.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.11.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.12.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.13.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.14.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.15.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.2.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.3.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.4.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.5.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.6.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.7.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.8.rcgu.o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.diesel.24nhi1y9-cgu.9.rcgu.o" "-o" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5" "/tmp/cargo-install3qoTms/release/deps/diesel-4f6d9f62c2baa6c5.5cmsvjs1wdudc82c.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-install3qoTms/release/deps" "-L" "/tmp/cargo-install3qoTms/release/build/backtrace-sys-3ef25736b63c5d65/out" "-L" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-install3qoTms/release/deps/liburl-7fab491cf6a0f920.rlib" "/tmp/cargo-install3qoTms/release/deps/libpercent_encoding-f6efc28bdf3e3b8b.rlib" "/tmp/cargo-install3qoTms/release/deps/libidna-58971beeb5f3e72a.rlib" "/tmp/cargo-install3qoTms/release/deps/libunicode_normalization-ba1d9484f5a73897.rlib" "/tmp/cargo-install3qoTms/release/deps/libsmallvec-22b142501f95f7f5.rlib" "/tmp/cargo-install3qoTms/release/deps/libunicode_bidi-127b6dea613aa070.rlib" "/tmp/cargo-install3qoTms/release/deps/libmatches-656cd79ac1f4dbf3.rlib" "/tmp/cargo-install3qoTms/release/deps/libtoml-dfed45e8dfb8f0f0.rlib" "/tmp/cargo-install3qoTms/release/deps/libtempfile-7a3a45da5978e8c3.rlib" "/tmp/cargo-install3qoTms/release/deps/librand-0063ba157aa55ab6.rlib" "/tmp/cargo-install3qoTms/release/deps/librand_chacha-ec030bb7dee8a2fa.rlib" "/tmp/cargo-install3qoTms/release/deps/libc2_chacha-c8eda0f20f7e2f0e.rlib" "/tmp/cargo-install3qoTms/release/deps/libppv_lite86-a04a8f11e34d8925.rlib" "/tmp/cargo-install3qoTms/release/deps/librand_core-1fd1a9ccea3f07fa.rlib" "/tmp/cargo-install3qoTms/release/deps/libgetrandom-c0a51d1a68e3b168.rlib" "/tmp/cargo-install3qoTms/release/deps/libremove_dir_all-a62e477b0056a536.rlib" "/tmp/cargo-install3qoTms/release/deps/libserde-0834154bd4bb3848.rlib" "/tmp/cargo-install3qoTms/release/deps/libmigrations_internals-ff5bf533c82a16b2.rlib" "/tmp/cargo-install3qoTms/release/deps/libdotenv-e5fb9eb87bc25999.rlib" "/tmp/cargo-install3qoTms/release/deps/libregex-119c629626029e55.rlib" "/tmp/cargo-install3qoTms/release/deps/libutf8_ranges-e30b52371fec80ac.rlib" "/tmp/cargo-install3qoTms/release/deps/libregex_syntax-8ae96e5edc990158.rlib" "/tmp/cargo-install3qoTms/release/deps/libucd_util-5d66fe41e708977f.rlib" "/tmp/cargo-install3qoTms/release/deps/libthread_local-fbdfc22547376d59.rlib" "/tmp/cargo-install3qoTms/release/deps/liblazy_static-9927bdb5a51d8866.rlib" "/tmp/cargo-install3qoTms/release/deps/libaho_corasick-44e9f6b19a174986.rlib" "/tmp/cargo-install3qoTms/release/deps/libmemchr-0e058df740fee616.rlib" "/tmp/cargo-install3qoTms/release/deps/liberror_chain-d809cc769fec46c3.rlib" "/tmp/cargo-install3qoTms/release/deps/libbacktrace-f578ec356b389e3b.rlib" "/tmp/cargo-install3qoTms/release/deps/libbacktrace_sys-4ee89146f2e59bea.rlib" "/tmp/cargo-install3qoTms/release/deps/libcfg_if-f51889ee12a5a31e.rlib" "/tmp/cargo-install3qoTms/release/deps/librustc_demangle-2518b9cc69d3ccce.rlib" "/tmp/cargo-install3qoTms/release/deps/libdiesel-ce4f8ad2332a3975.rlib" "/tmp/cargo-install3qoTms/release/deps/libpq_sys-4686e6c9e1f253f4.rlib" "/tmp/cargo-install3qoTms/release/deps/libbyteorder-8dbacdfd1cfce70a.rlib" "/tmp/cargo-install3qoTms/release/deps/libclap-093260f6c8c01d00.rlib" "/tmp/cargo-install3qoTms/release/deps/libvec_map-55ef90d900f59167.rlib" "/tmp/cargo-install3qoTms/release/deps/libtextwrap-43efb029aa87cfae.rlib" "/tmp/cargo-install3qoTms/release/deps/libunicode_width-046c2037716ab9fc.rlib" "/tmp/cargo-install3qoTms/release/deps/libstrsim-cf1cb4eac4c7d4dd.rlib" "/tmp/cargo-install3qoTms/release/deps/libbitflags-1ce435d9d7344b5e.rlib" "/tmp/cargo-install3qoTms/release/deps/libatty-f85bb1b093fac9e5.rlib" "/tmp/cargo-install3qoTms/release/deps/libansi_term-95473dff1895eeed.rlib" "/tmp/cargo-install3qoTms/release/deps/libchrono-d53da1bfb5b41d7a.rlib" "/tmp/cargo-install3qoTms/release/deps/libnum_integer-1a510640678c8078.rlib" "/tmp/cargo-install3qoTms/release/deps/libnum_traits-e9f7da71647d3cfe.rlib" "/tmp/cargo-install3qoTms/release/deps/libtime-0c5965e3d0ac56c3.rlib" "/tmp/cargo-install3qoTms/release/deps/liblibc-6ee876d788dfcf50.rlib" "-Wl,--start-group" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-fae576517123aa4e.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-a72070139220275e.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-093434daf7d99801.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-24daf38551b7a03b.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-36d70d9746402ce9.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-7acfc843240167a8.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-eb2e0f5fe057b8b3.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-75e9ddd83715a368.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-af51e7c6fd7d1248.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-27f2a77b2995d98c.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-ad10152c26711a1e.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-291bd2456cb6c9fe.rlib" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fc6e9071307a3016.rlib" "-Wl,--end-group" "/home/bryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ebe4001ded7f33e7.rlib" "-Wl,-Bdynamic" "-lpq" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
= note: /usr/bin/ld: cannot find -lpq
collect2: error: ld returned 1 exit status

error: aborting due to previous error

error: failed to compile diesel_cli v1.4.0, intermediate artifacts can be found at /tmp/cargo-install3qoTms

Caused by:
could not compile diesel_cli.

To learn more, run the command again with --verbose.

Please help me.
Ubuntu 18.04.3
psql --version returns 12.1

I am a complete newbie.

Try:

sudo apt-get install libpq-dev

This contains the development files that are required to build the Postgresql driver against.

Thank you so much @osrust. It worked.

1 Like