2
votes

I'm trying to add sqlite support in my rust project. I found rusqlite on crates.io. I added the version line to Cargo.toml. I added some imports (unused) that I found on the rusqlite docs page. After running car go build I revived an error.

I hadn't implemented anything yet. I just wanted to get the dependency added and compiling. main.rs:

extern crate rusqlite;

use rusqlite::{Connection, Result};
use rusqlite::NO_PARAMS;

Cargo.toml:

[package]
name = "program"
version = "0.1.0"
authors = ["97"]

[dependencies]
argparse = "0.2.2"
rand = "0.4.0"
rusqlite = "0.20.0"

Error recived:

$ cargo build
   Compiling pkg-config v0.3.16
   Compiling fallible-iterator v0.2.0
   Compiling memchr v2.2.1
   Compiling bitflags v1.2.1
   Compiling lru-cache v0.1.2
error[E0432]: unresolved import `std::ops::Bound`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.16/src/lib.rs:72:16
   |
72 | use std::ops::{Bound, RangeBounds};
   |                ^^^^^ no `Bound` in `ops`

error[E0432]: unresolved import `std::ops::RangeBounds`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.16/src/lib.rs:72:23
   |
72 | use std::ops::{Bound, RangeBounds};
   |                       ^^^^^^^^^^^ no `RangeBounds` in `ops`

error[E0658]: `dyn Trait` syntax is unstable (see issue #44662)
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.16/src/lib.rs:143:32
    |
143 |     fn cause(&self) -> Option<&dyn error::Error> {
    |                                ^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

error: Could not compile `pkg-config`.
warning: build failed, waiting for other jobs to finish...
error[E0658]: `crate` in paths is experimental (see issue #45477)
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/fallible-iterator-0.2.0/src/lib.rs:98:5
   |
98 | use crate::imports::*;
   |     ^^^^^

error[E0658]: `dyn Trait` syntax is unstable (see issue #44662)
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/fallible-iterator-0.2.0/src/lib.rs:2606:24
     |
2606 | fn _is_object_safe(_: &dyn DoubleEndedFallibleIterator<Item = (), Error = ()>) {}
     |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `fallible-iterator`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Edit

cargo 0.26.0 (41480f5cc 2018-02-26)

rustc 1.25.0 (84203cac6 2018-03-25)

1
Are you perhaps running an old version of Rust? Have you updated recently? Bound was added in 1.17.0 and RangeBounds in 1.28.0.loganfsmyth
@loganfsmyth cargo --version [RET] cargo 0.26.0 (41480f5cc 2018-02-26)9716278
@loganfsmyth (Sorry. Forgot cargo and rustc are not the same.) rustc 1.25.0 (84203cac6 2018-03-25). It must be RangeBounds then. Do you know which version of rusqlite works with rust 1.25?9716278
I don't know, and there isn't guaranteed to be one. Would you be able to update? As you can see from that date, your version is more than a year and a half behind.loganfsmyth
@loganfsmyth I could probably update. Just run rustup again, right?9716278

1 Answers

1
votes

Most crates support only the latest Rust version. You could try to use an older version of the crate, but the easiest way is to update Rust to a currently-supported version.

If you're using Rust from a Linux distro, then uninstall it, and get it from https://rustup.rs which can keep it up to date. Rust ecosystem moves much faster than most distributions.

Run rustup update.