dieselが大量のエラーを掃き出してインストールされないときの対処方

問題

dieselのチュートリアルの通りにインストールしようとした。 コマンドは

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

これでインストールしようとすると、大量のエラー

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.0.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.1.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.10.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.11.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.12.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.13.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.14.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.15.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.2.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.3.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.4.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.5.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.6.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.7.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.8.rcgu.o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.diesel.3yhc16ed-cgu.9.rcgu.o" "-o" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae" "/tmp/cargo-installl7MMnA/release/deps/diesel-f9383feb9231cfae.2ljx8vxpfob2gs4q.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-installl7MMnA/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installl7MMnA/release/deps/liburl-467eaddfcce53554.rlib" "/tmp/cargo-installl7MMnA/release/deps/libpercent_encoding-6404fa3895139f99.rlib" "/tmp/cargo-installl7MMnA/release/deps/libidna-1cf68800b7ed22b1.rlib" "/tmp/cargo-installl7MMnA/release/deps/libunicode_normalization-65fa459eef99a4b7.rlib" "/tmp/cargo-installl7MMnA/release/deps/libtinyvec-3c50fc017bbed66b.rlib" "/tmp/cargo-installl7MMnA/release/deps/libunicode_bidi-d7adc887995a8f0b.rlib" "/tmp/cargo-installl7MMnA/release/deps/libmatches-389a53a8d07e8373.rlib" "/tmp/cargo-installl7MMnA/release/deps/libtoml-2f55c3bb86f27f38.rlib" "/tmp/cargo-installl7MMnA/release/deps/libtempfile-e18b97729444a80f.rlib" "/tmp/cargo-installl7MMnA/release/deps/librand-2a54687171897a17.rlib" "/tmp/cargo-installl7MMnA/release/deps/librand_chacha-611571fee6109426.rlib" "/tmp/cargo-installl7MMnA/release/deps/libppv_lite86-7acc70b7fe3e6300.rlib" "/tmp/cargo-installl7MMnA/release/deps/librand_core-dd9c19cb313f4f24.rlib" "/tmp/cargo-installl7MMnA/release/deps/libgetrandom-3493a36dcbda61cc.rlib" "/tmp/cargo-installl7MMnA/release/deps/libremove_dir_all-e105efd57f3eec17.rlib" "/tmp/cargo-installl7MMnA/release/deps/libcfg_if-0f89700f04afbfc5.rlib" "/tmp/cargo-installl7MMnA/release/deps/libserde-3465af54848603e5.rlib" "/tmp/cargo-installl7MMnA/release/deps/libmigrations_internals-239d6c6fa4d17fa3.rlib" "/tmp/cargo-installl7MMnA/release/deps/libdotenv-8bb50913892f7b18.rlib" "/tmp/cargo-installl7MMnA/release/deps/libregex-a4a15eaf73f6b450.rlib" "/tmp/cargo-installl7MMnA/release/deps/libutf8_ranges-24dc3098c5a9996e.rlib" "/tmp/cargo-installl7MMnA/release/deps/libregex_syntax-c181b1c5b45966ed.rlib" "/tmp/cargo-installl7MMnA/release/deps/libucd_util-3a31297ed9e71b37.rlib" "/tmp/cargo-installl7MMnA/release/deps/libthread_local-7f22dce31c3b8610.rlib" "/tmp/cargo-installl7MMnA/release/deps/liblazy_static-a2d4e9568ec6e14c.rlib" "/tmp/cargo-installl7MMnA/release/deps/libaho_corasick-1f870e1cc8698ef1.rlib" "/tmp/cargo-installl7MMnA/release/deps/libmemchr-ad18c58549176d99.rlib" "/tmp/cargo-installl7MMnA/release/deps/liberror_chain-07208c47f3f894a2.rlib" "/tmp/cargo-installl7MMnA/release/deps/libbacktrace-4f92aa72f2665e9a.rlib" "/tmp/cargo-installl7MMnA/release/deps/libminiz_oxide-832fc9383d1c709f.rlib" "/tmp/cargo-installl7MMnA/release/deps/libadler-db4c0f56e21a0544.rlib" "/tmp/cargo-installl7MMnA/release/deps/libobject-ff42ba3d842bf54f.rlib" "/tmp/cargo-installl7MMnA/release/deps/libaddr2line-49fa3ae780197da5.rlib" "/tmp/cargo-installl7MMnA/release/deps/libgimli-bdcfc0588434ee82.rlib" "/tmp/cargo-installl7MMnA/release/deps/libcfg_if-6d7e6186e726238c.rlib" "/tmp/cargo-installl7MMnA/release/deps/librustc_demangle-759799f7a70b78ca.rlib" "/tmp/cargo-installl7MMnA/release/deps/libdiesel-deb5637a5f67f223.rlib" "/tmp/cargo-installl7MMnA/release/deps/libpq_sys-86aaf66686c5e02e.rlib" "/tmp/cargo-installl7MMnA/release/deps/libbyteorder-eb338c1472124957.rlib" "/tmp/cargo-installl7MMnA/release/deps/libclap-1df416366c8280d8.rlib" "/tmp/cargo-installl7MMnA/release/deps/libvec_map-405e6da89d886d17.rlib" "/tmp/cargo-installl7MMnA/release/deps/libtextwrap-ab9ff3722de2db3a.rlib" "/tmp/cargo-installl7MMnA/release/deps/libunicode_width-5f4356788e200ee8.rlib" "/tmp/cargo-installl7MMnA/release/deps/libstrsim-4674324dc7d46173.rlib" "/tmp/cargo-installl7MMnA/release/deps/libbitflags-ff7f5482904c4de3.rlib" "/tmp/cargo-installl7MMnA/release/deps/libatty-77e74e8a1493e544.rlib" "/tmp/cargo-installl7MMnA/release/deps/libansi_term-51c4c3bdcd4f8b68.rlib" "/tmp/cargo-installl7MMnA/release/deps/libchrono-dadbce334e241555.rlib" "/tmp/cargo-installl7MMnA/release/deps/libnum_integer-68daeca7f4931930.rlib" "/tmp/cargo-installl7MMnA/release/deps/libnum_traits-57b35a11280e5fc4.rlib" "/tmp/cargo-installl7MMnA/release/deps/libtime-18a87bf33e135542.rlib" "/tmp/cargo-installl7MMnA/release/deps/liblibc-171b7f68884a56a2.rlib" "-Wl,--start-group" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f14aca24435a5414.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-48d342a8b48d1d01.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-14bc0820888c8eb3.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-9cbd9e217bff06bc.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-31826136df98934e.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-075976a117c8fd5d.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-2d5cbedfbf17a011.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-0474372ff08c5319.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-d437c34460d2315a.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-fb61ed1b8cc4de79.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-bf76d1b643bfc9f0.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-a1b53aa7fddcf418.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-28585e57fac45c73.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-64801769bc15ab28.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-541997b56bb98660.rlib" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-cdea3c81adab3d12.rlib" "-Wl,--end-group" "/home/hikarukondo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-cd9f15a39fb65cbc.rlib" "-Wl,-Bdynamic" "-lpq" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-ldl" "-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.1`, intermediate artifacts can be found at `/tmp/cargo-installl7MMnA`

Caused by:
  could not compile `diesel_cli`.

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

対処方 githubのissueに記載があった。

sudo apt install libpq-dev

で解決した。