Could not compile diesel_codegen

I am new to Rust. I am following a Youtube video building a simple API in Rust. One of the dependencies I need diesel_codegen and here is the line in the cargo.toml file:

diesel_codegen = {version = "0.16.0", features = ["postgres"]}

I am running Rust version 1.50.0
There is an error saying "Could not compile diesel_codegen
So I installed it again and now I get this error:
error: specified package diesel_codegen v0.16.1 has no binaries
Any help on how to solve this problem is greatly appreciated.

You can't use cargo install to install a library package. Just adding it to your Cargo.toml is enough. Cargo will automatically download and compile it when you build or run your code, with a command like:

cargo build

If you need to install the diesel_cli binary package, run this command:

cargo install diesel_cli
1 Like

Ok thanks I did install diesel_cli before and got the error. Did not know about you shouldn't use cargo install to install a library package, but also wondering why it allows me to install it in the first place? I went ahead and ran the command to install diesel_cli ad I got a massive error:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.0.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.1.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.10.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.11.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.12.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.13.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.14.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.15.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.2.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.3.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.4.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.5.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.6.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.7.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.8.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.9.rcgu.o" "-o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.2gyfjtchojehai8l.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-installJrePI6/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installJrePI6/release/deps/libtoml-4f340de4b73616ab.rlib" "/tmp/cargo-installJrePI6/release/deps/libtempfile-1f51e4f0c66d1e5d.rlib" "/tmp/cargo-installJrePI6/release/deps/librand-0058ecfa4ab2fdb9.rlib" "/tmp/cargo-installJrePI6/release/deps/librand_chacha-91f800a4526da674.rlib" "/tmp/cargo-installJrePI6/release/deps/libppv_lite86-4aad96f58c304b26.rlib" "/tmp/cargo-installJrePI6/release/deps/librand_core-b3a2ed127d4b8b3b.rlib" "/tmp/cargo-installJrePI6/release/deps/libgetrandom-e2fdaa8744eed76f.rlib" "/tmp/cargo-installJrePI6/release/deps/libremove_dir_all-35551f2e396fa83e.rlib" "/tmp/cargo-installJrePI6/release/deps/libserde-a7a136f202509139.rlib" "/tmp/cargo-installJrePI6/release/deps/libmigrations_internals-63acd035dca4d478.rlib" "/tmp/cargo-installJrePI6/release/deps/libdotenv-122b1a021f8676d7.rlib" "/tmp/cargo-installJrePI6/release/deps/libregex-ffad36622da47c82.rlib" "/tmp/cargo-installJrePI6/release/deps/libutf8_ranges-a1f46f73850bb981.rlib" "/tmp/cargo-installJrePI6/release/deps/libregex_syntax-2608940a61c4a55a.rlib" "/tmp/cargo-installJrePI6/release/deps/libucd_util-d0e193eeb17475cb.rlib" "/tmp/cargo-installJrePI6/release/deps/libthread_local-b76d60cb3b0ff40f.rlib" "/tmp/cargo-installJrePI6/release/deps/liblazy_static-7838e4e1e8aa819d.rlib" "/tmp/cargo-installJrePI6/release/deps/libaho_corasick-e4df4b6fbc625909.rlib" "/tmp/cargo-installJrePI6/release/deps/libmemchr-b069fee841f12d3e.rlib" "/tmp/cargo-installJrePI6/release/deps/liberror_chain-b312eeb6d0a870f0.rlib" "/tmp/cargo-installJrePI6/release/deps/libbacktrace-8dfc3f5c5285c05a.rlib" "/tmp/cargo-installJrePI6/release/deps/libminiz_oxide-a8bf6954a40d2e67.rlib" "/tmp/cargo-installJrePI6/release/deps/libadler-3d2dfd5868192abb.rlib" "/tmp/cargo-installJrePI6/release/deps/libobject-9be1ef9b7785053d.rlib" "/tmp/cargo-installJrePI6/release/deps/libaddr2line-e2f1bfbbe48e656e.rlib" "/tmp/cargo-installJrePI6/release/deps/libgimli-4fabdeae3b437c69.rlib" "/tmp/cargo-installJrePI6/release/deps/libcfg_if-6443c9fece9c5a8b.rlib" "/tmp/cargo-installJrePI6/release/deps/librustc_demangle-f4ab8b54ec54ece8.rlib" "/tmp/cargo-installJrePI6/release/deps/libdiesel-749dfd6c21231436.rlib" "/tmp/cargo-installJrePI6/release/deps/liblibsqlite3_sys-3f9d56672e57ca0d.rlib" "/tmp/cargo-installJrePI6/release/deps/libpq_sys-aafda7f2bb945a88.rlib" "/tmp/cargo-installJrePI6/release/deps/liburl-434ac20774a64d97.rlib" "/tmp/cargo-installJrePI6/release/deps/libpercent_encoding-5ceff6c3a4c24c73.rlib" "/tmp/cargo-installJrePI6/release/deps/libidna-998d0e1d893c1e66.rlib" "/tmp/cargo-installJrePI6/release/deps/libunicode_normalization-dbb668f724d1b981.rlib" "/tmp/cargo-installJrePI6/release/deps/libtinyvec-322d847c60b8e647.rlib" "/tmp/cargo-installJrePI6/release/deps/libtinyvec_macros-26f28bf321070a5e.rlib" "/tmp/cargo-installJrePI6/release/deps/libunicode_bidi-69326d5e28523a54.rlib" "/tmp/cargo-installJrePI6/release/deps/libmatches-49f64d78ac8b77d2.rlib" "/tmp/cargo-installJrePI6/release/deps/libmysqlclient_sys-837c32ce0fa9463a.rlib" "/tmp/cargo-installJrePI6/release/deps/libbyteorder-ecdd2247ed3a0ae9.rlib" "/tmp/cargo-installJrePI6/release/deps/libclap-8fc25df63bc82167.rlib" "/tmp/cargo-installJrePI6/release/deps/libvec_map-aa70a9b8a46da868.rlib" "/tmp/cargo-installJrePI6/release/deps/libtextwrap-fa17f008fcb6a641.rlib" "/tmp/cargo-installJrePI6/release/deps/libunicode_width-788a7bb8f6848a2f.rlib" "/tmp/cargo-installJrePI6/release/deps/libstrsim-0f90bfc1e86d296f.rlib" "/tmp/cargo-installJrePI6/release/deps/libbitflags-ce22fd3ba40b4cc7.rlib" "/tmp/cargo-installJrePI6/release/deps/libatty-77d55ca7120f798c.rlib" "/tmp/cargo-installJrePI6/release/deps/libansi_term-87d88f946b658a4b.rlib" "/tmp/cargo-installJrePI6/release/deps/libchrono-4de79792d658d740.rlib" "/tmp/cargo-installJrePI6/release/deps/libnum_integer-f11d99110948e2d4.rlib" "/tmp/cargo-installJrePI6/release/deps/libnum_traits-1922c207acd96335.rlib" "/tmp/cargo-installJrePI6/release/deps/libtime-10d9973795419991.rlib" "/tmp/cargo-installJrePI6/release/deps/liblibc-d127b7de7160350f.rlib" "-Wl,--start-group" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e238540f8faf9927.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-78f8506dd5004913.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-c0e64497deb085aa.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-217a514dc8d845c6.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-65e4f8df4b8bbd73.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-fec1b74170245419.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-e74f867eb2f15322.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-72a374d36f3d0a31.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-cb9206ed96de54c3.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-33ee81149d314805.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-2e8740599b11634b.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-241cf59851357bea.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-edc29aa8c04b480f.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-6a141406945fda5a.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2408224b4af46d83.rlib" "-Wl,--end-group" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d36087076e1dd756.rlib" "-Wl,-Bdynamic" "-lsqlite3" "-lpq" "-lmysqlclient" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/bin/ld: cannot find -lsqlite3
          /usr/bin/ld: cannot find -lmysqlclient
          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-installJrePI6`

Caused by:
  could not compile `diesel_cli`

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

Cargo doesn't know whether it's a binary or library until after it downloads the package.

If you only have the Postgres libraries installed, try this command from the Diesel documentation:

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

Thanks for the info

I ran this exact command when I started the project and I got the error "Could not compile diesel_codegen. That is why I actually tried to install it using cargo install

If you still get an error about diesel_codegen when installing cargo_cli, please paste the entire error message here.

Yes I did paste the entire error message in this thread two messages back and here is the JSON file in the artifacts

{"rustc_fingerprint":2550884865008398446,"outputs":{"1164083562126845933":["rustc 1.50.0 (cb75ad5db 2021-02-10)\nbinary: rustc\ncommit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b\ncommit-date: 2021-02-10\nhost: x86_64-unknown-linux-gnu\nrelease: 1.50.0\n",""],"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}}

but here it is again:

(renv) calvin@lapcaltop:/media/calvin/240GB/computers/learning/rust/buildapi/buildapi$ cargo install diesel_cli
    Updating crates.io index
  Installing diesel_cli v1.4.1
  Downloaded libc v0.2.87
  Downloaded mysqlclient-sys v0.2.4
  Downloaded pkg-config v0.3.19
  Downloaded libsqlite3-sys v0.18.0
  Downloaded 4 crates (2.8 MB) in 2.96s (largest was `libsqlite3-sys` at 2.3 MB)
   Compiling libc v0.2.87
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling pkg-config v0.3.19
   Compiling cfg-if v1.0.0
   Compiling syn v1.0.60
   Compiling getrandom v0.2.2
   Compiling tinyvec_macros v0.1.0
   Compiling memchr v2.3.4
   Compiling bitflags v1.2.1
   Compiling matches v0.1.8
   Compiling pq-sys v0.4.6
   Compiling serde_derive v1.0.123
   Compiling adler v1.0.2
   Compiling gimli v0.23.0
   Compiling unicode-xid v0.0.4
   Compiling regex v0.2.11
   Compiling lazy_static v1.4.0
   Compiling ucd-util v0.1.8
   Compiling serde v1.0.123
   Compiling rustc-demangle v0.1.18
   Compiling object v0.23.0
   Compiling percent-encoding v1.0.1
   Compiling ppv-lite86 v0.2.10
   Compiling quote v0.3.15
   Compiling byteorder v1.4.2
   Compiling utf8-ranges v1.0.4
   Compiling unicode-width v0.1.8
   Compiling ansi_term v0.11.0
   Compiling remove_dir_all v0.5.3
   Compiling vec_map v0.8.2
   Compiling strsim v0.8.0
   Compiling miniz_oxide v0.4.4
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling tinyvec v1.1.1
   Compiling mysqlclient-sys v0.2.4
   Compiling libsqlite3-sys v0.18.0
   Compiling unicode-bidi v0.3.4
   Compiling synom v0.11.3
   Compiling thread_local v0.3.6
   Compiling regex-syntax v0.5.6
   Compiling addr2line v0.14.1
   Compiling textwrap v0.11.0
   Compiling syn v0.11.11
   Compiling unicode-normalization v0.1.17
   Compiling quote v1.0.9
   Compiling time v0.1.43
   Compiling atty v0.2.14
   Compiling aho-corasick v0.6.10
   Compiling idna v0.1.5
   Compiling backtrace v0.3.56
   Compiling derive-error-chain v0.10.1
   Compiling rand_core v0.6.2
   Compiling clap v2.33.3
   Compiling url v1.7.2
   Compiling error-chain v0.10.0
   Compiling chrono v0.4.19
   Compiling rand_chacha v0.3.0
   Compiling diesel_derives v1.4.1
   Compiling dotenv v0.10.1
   Compiling rand v0.8.3
   Compiling tempfile v3.2.0
   Compiling diesel v1.4.5
   Compiling toml v0.4.10
   Compiling migrations_internals v1.4.1
   Compiling diesel_cli v1.4.1
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.0.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.1.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.10.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.11.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.12.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.13.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.14.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.15.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.2.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.3.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.4.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.5.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.6.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.7.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.8.rcgu.o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.diesel.1b32swr7-cgu.9.rcgu.o" "-o" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3" "/tmp/cargo-installJrePI6/release/deps/diesel-2651bf31b34c86f3.2gyfjtchojehai8l.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-installJrePI6/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installJrePI6/release/deps/libtoml-4f340de4b73616ab.rlib" "/tmp/cargo-installJrePI6/release/deps/libtempfile-1f51e4f0c66d1e5d.rlib" "/tmp/cargo-installJrePI6/release/deps/librand-0058ecfa4ab2fdb9.rlib" "/tmp/cargo-installJrePI6/release/deps/librand_chacha-91f800a4526da674.rlib" "/tmp/cargo-installJrePI6/release/deps/libppv_lite86-4aad96f58c304b26.rlib" "/tmp/cargo-installJrePI6/release/deps/librand_core-b3a2ed127d4b8b3b.rlib" "/tmp/cargo-installJrePI6/release/deps/libgetrandom-e2fdaa8744eed76f.rlib" "/tmp/cargo-installJrePI6/release/deps/libremove_dir_all-35551f2e396fa83e.rlib" "/tmp/cargo-installJrePI6/release/deps/libserde-a7a136f202509139.rlib" "/tmp/cargo-installJrePI6/release/deps/libmigrations_internals-63acd035dca4d478.rlib" "/tmp/cargo-installJrePI6/release/deps/libdotenv-122b1a021f8676d7.rlib" "/tmp/cargo-installJrePI6/release/deps/libregex-ffad36622da47c82.rlib" "/tmp/cargo-installJrePI6/release/deps/libutf8_ranges-a1f46f73850bb981.rlib" "/tmp/cargo-installJrePI6/release/deps/libregex_syntax-2608940a61c4a55a.rlib" "/tmp/cargo-installJrePI6/release/deps/libucd_util-d0e193eeb17475cb.rlib" "/tmp/cargo-installJrePI6/release/deps/libthread_local-b76d60cb3b0ff40f.rlib" "/tmp/cargo-installJrePI6/release/deps/liblazy_static-7838e4e1e8aa819d.rlib" "/tmp/cargo-installJrePI6/release/deps/libaho_corasick-e4df4b6fbc625909.rlib" "/tmp/cargo-installJrePI6/release/deps/libmemchr-b069fee841f12d3e.rlib" "/tmp/cargo-installJrePI6/release/deps/liberror_chain-b312eeb6d0a870f0.rlib" "/tmp/cargo-installJrePI6/release/deps/libbacktrace-8dfc3f5c5285c05a.rlib" "/tmp/cargo-installJrePI6/release/deps/libminiz_oxide-a8bf6954a40d2e67.rlib" "/tmp/cargo-installJrePI6/release/deps/libadler-3d2dfd5868192abb.rlib" "/tmp/cargo-installJrePI6/release/deps/libobject-9be1ef9b7785053d.rlib" "/tmp/cargo-installJrePI6/release/deps/libaddr2line-e2f1bfbbe48e656e.rlib" "/tmp/cargo-installJrePI6/release/deps/libgimli-4fabdeae3b437c69.rlib" "/tmp/cargo-installJrePI6/release/deps/libcfg_if-6443c9fece9c5a8b.rlib" "/tmp/cargo-installJrePI6/release/deps/librustc_demangle-f4ab8b54ec54ece8.rlib" "/tmp/cargo-installJrePI6/release/deps/libdiesel-749dfd6c21231436.rlib" "/tmp/cargo-installJrePI6/release/deps/liblibsqlite3_sys-3f9d56672e57ca0d.rlib" "/tmp/cargo-installJrePI6/release/deps/libpq_sys-aafda7f2bb945a88.rlib" "/tmp/cargo-installJrePI6/release/deps/liburl-434ac20774a64d97.rlib" "/tmp/cargo-installJrePI6/release/deps/libpercent_encoding-5ceff6c3a4c24c73.rlib" "/tmp/cargo-installJrePI6/release/deps/libidna-998d0e1d893c1e66.rlib" "/tmp/cargo-installJrePI6/release/deps/libunicode_normalization-dbb668f724d1b981.rlib" "/tmp/cargo-installJrePI6/release/deps/libtinyvec-322d847c60b8e647.rlib" "/tmp/cargo-installJrePI6/release/deps/libtinyvec_macros-26f28bf321070a5e.rlib" "/tmp/cargo-installJrePI6/release/deps/libunicode_bidi-69326d5e28523a54.rlib" "/tmp/cargo-installJrePI6/release/deps/libmatches-49f64d78ac8b77d2.rlib" "/tmp/cargo-installJrePI6/release/deps/libmysqlclient_sys-837c32ce0fa9463a.rlib" "/tmp/cargo-installJrePI6/release/deps/libbyteorder-ecdd2247ed3a0ae9.rlib" "/tmp/cargo-installJrePI6/release/deps/libclap-8fc25df63bc82167.rlib" "/tmp/cargo-installJrePI6/release/deps/libvec_map-aa70a9b8a46da868.rlib" "/tmp/cargo-installJrePI6/release/deps/libtextwrap-fa17f008fcb6a641.rlib" "/tmp/cargo-installJrePI6/release/deps/libunicode_width-788a7bb8f6848a2f.rlib" "/tmp/cargo-installJrePI6/release/deps/libstrsim-0f90bfc1e86d296f.rlib" "/tmp/cargo-installJrePI6/release/deps/libbitflags-ce22fd3ba40b4cc7.rlib" "/tmp/cargo-installJrePI6/release/deps/libatty-77d55ca7120f798c.rlib" "/tmp/cargo-installJrePI6/release/deps/libansi_term-87d88f946b658a4b.rlib" "/tmp/cargo-installJrePI6/release/deps/libchrono-4de79792d658d740.rlib" "/tmp/cargo-installJrePI6/release/deps/libnum_integer-f11d99110948e2d4.rlib" "/tmp/cargo-installJrePI6/release/deps/libnum_traits-1922c207acd96335.rlib" "/tmp/cargo-installJrePI6/release/deps/libtime-10d9973795419991.rlib" "/tmp/cargo-installJrePI6/release/deps/liblibc-d127b7de7160350f.rlib" "-Wl,--start-group" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e238540f8faf9927.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-78f8506dd5004913.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-c0e64497deb085aa.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-217a514dc8d845c6.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-65e4f8df4b8bbd73.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-fec1b74170245419.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-e74f867eb2f15322.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-72a374d36f3d0a31.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-cb9206ed96de54c3.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-33ee81149d314805.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-2e8740599b11634b.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-241cf59851357bea.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-edc29aa8c04b480f.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-6a141406945fda5a.rlib" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2408224b4af46d83.rlib" "-Wl,--end-group" "/media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d36087076e1dd756.rlib" "-Wl,-Bdynamic" "-lsqlite3" "-lpq" "-lmysqlclient" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/bin/ld: cannot find -lsqlite3
          /usr/bin/ld: cannot find -lmysqlclient
          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-installJrePI6`

Caused by:
  could not compile `diesel_cli`

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

The error message you pasted does not mention anything about diesel_codegen. That error is about missing sqlite3 and mysqlclient libraries. You can fix it by installing those libraries, or disabling the default features of diesel_cli.

That error is from running the command cargo install diesel_cli

The error about diesel_codegen I see in my IDE that says Could not compile diesel_codegen

Can you please paste the full text of the diesel_codegen error? If you can't copy it from your IDE, or if your IDE doesn't show any detailed error messages, try running this command in a terminal, in your project directory:

cargo build

cargo install diesel_cli installs for Sqlite and MySQL, which you don't have, so it will fail. This is normal and expected.

It is very important that you add additional arguments that specify that you want only postgres, and nothing else:

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

I am using VS Code and in the terminal there is a tab called Problems. Under that tab is a message "could not compile diesel_codegen" and all the text in the Cargo.toml file is red underlined and if you hover the red underlined text it gives the same message. That is all I see. I did not get any other messages or errors about diesel_codegen. I have not finished the project so I have not compiled or ran it. I am worried about the error and want to fix it before I compile the project.

but I went ahead and ran cargo build and this is the output:

error[E0659]: `error_chain` is ambiguous (derive helper attribute vs any other name)
  --> /media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/registry/src/github.com-1ecc6299db9ec823/dotenv-0.10.1/src/lib.rs:23:40
   |
23 | #[cfg_attr(not(feature = "backtrace"), error_chain(backtrace = "false"))]
   |                                        ^^^^^^^^^^^ ambiguous name
   |
note: `error_chain` could refer to the derive helper attribute defined here
  --> /media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/registry/src/github.com-1ecc6299db9ec823/dotenv-0.10.1/src/lib.rs:22:17
   |
22 | #[derive(Debug, error_chain)]
   |                 ^^^^^^^^^^^
note: `error_chain` could also refer to the derive macro imported here
  --> /media/calvin/240GB/computers/learning/rust/buildapi/buildapi/renv/rust/registry/src/github.com-1ecc6299db9ec823/dotenv-0.10.1/src/lib.rs:10:1
   |
10 | #[macro_use]
   | ^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0659`.
error: could not compile `dotenv`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Hmm. This is a tricky situation.

diesel_codegen depends on an old version of dotenv that broke in recent versions of the Rust compiler: Cannot compile `dotenv v0.10.1` · Issue #66508 · rust-lang/rust · GitHub

This was reported fixed a year ago, but I can reproduce the error in Rust 1.50.0, so it seems the fix either didn't work, or the bug reappeared again later.

The latest version of the diesel crate no longer depends on the old version of dotenv, so it is unaffected. But diesel_codegen is from an old version of Diesel, and is no longer updated.

If you want to build the exact code from that YouTube video, you might need to use an old version of the Rust toolchain. Alternately, you can use a more recent Diesel tutorial which no longer requires the old diesel_codegen crate.

1 Like

Thank you so much for the detailed explanation. I will make a plan and use the more recent Diesel tutorial.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.