Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsqlite3-sys version conflict in Rust SDK #5887

Closed
RandyPen opened this issue Nov 6, 2022 · 8 comments · Fixed by #6047
Closed

libsqlite3-sys version conflict in Rust SDK #5887

RandyPen opened this issue Nov 6, 2022 · 8 comments · Fixed by #6047
Assignees
Labels
devx Priority: High Very important task, not blocking but potentially delaying milestones or limiting our offering rust Pull requests that update Rust code rust-sdk sui-devx-oncall

Comments

@RandyPen
Copy link
Contributor

RandyPen commented Nov 6, 2022

Steps to Reproduce Issue

Follow this tutorial, add the sui-sdk crate in Cargo.toml file

[dependencies]
sui-sdk = { git = "https://github.com/MystenLabs/sui", branch = "devnet" }

Then run example code.

use std::str::FromStr;
use sui_sdk::types::base_types::SuiAddress;
use sui_sdk::SuiClient;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let sui = SuiClient::new_rpc_client("https://fullnode.devnet.sui.io:443", None).await?;
    let address = SuiAddress::from_str("0xec11cad080d0496a53bafcea629fcbcfff2a9866")?;
    let objects = sui.read_api().get_objects_owned_by_address(address).await?;
    println!("{:?}", objects);
    Ok(())
}

Compile Error

error: failed to select a version for `libsqlite3-sys`.
    ... required by package `sqlx-core v0.6.2 (https://github.com/huitseeker/sqlx?branch=update_libsqlite3#fa4613e7)`
    ... which satisfies git dependency `sqlx-core` of package `sqlx v0.6.2 (https://github.com/huitseeker/sqlx?branch=update_libsqlite3#fa4613e7)`
    ... which satisfies git dependency `sqlx` of package `workspace-hack v0.1.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `workspace-hack` of package `narwhal-config v0.1.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `config` of package `narwhal-consensus v0.1.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `consensus` of package `narwhal-executor v0.1.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `executor` of package `narwhal-node v0.1.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `narwhal-node` of package `sui-core v0.14.1 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `sui-core` of package `sui-cost v0.1.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `sui-cost` of package `sui-json-rpc v0.0.0 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `sui-json-rpc` of package `sui-sdk v0.14.1 (https://github.com/MystenLabs/sui?branch=devnet#0bc7d198)`
    ... which satisfies git dependency `sui-sdk` of package `rustctf-6 v0.1.0 (/Users/xxx/Code/rustctf-6)`
versions that meet the requirements `^0.25.1` are: 0.25.2, 0.25.1

the package `libsqlite3-sys` links to the native library `sqlite3`, but it conflicts with a previous package which links to `sqlite3` as well:
package `libsqlite3-sys v0.24.2`
    ... which satisfies dependency `libsqlite3-sys = "^0.24.2"` of package `rustctf-6 v0.1.0 (/Users/xxx/Code/rustctf-6)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='libsqlite3-sys' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `libsqlite3-sys` which could resolve this conflict

System Information

  • OS:
macOS Ventura
version 13.0
chip Apple M2
  • Compiler:
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
info: checking for self-updates

   stable-aarch64-apple-darwin unchanged - rustc 1.65.0 (897e37553 2022-11-02)
  nightly-aarch64-apple-darwin unchanged - rustc 1.67.0-nightly (1286ee23e 2022-11-05)

info: cleaning up downloads & tmp directories
cargo 1.65.0 (4bc8f24d3 2022-10-20)
  • Package:
sui v0.14.1 (https://github.com/MystenLabs/sui.git?branch=devnet#0bc7d198)
sui-node v0.14.1 (https://github.com/MystenLabs/sui.git?branch=devnet#0bc7d198)
@0x4ka5h
Copy link

0x4ka5h commented Nov 6, 2022

Yeah, I'm also facing the same issue.

@stella3d stella3d self-assigned this Nov 7, 2022
@wow-sven
Copy link

wow-sven commented Nov 7, 2022

[dependencies]
sui-sdk = { git = "https://github.com/MystenLabs/sui" }

macOS Monterey
version 12.6 (21G115)	
chip Intel Core i7
error: failed to select a version for `libsqlite3-sys`.
    ... required by package `sqlx-core v0.6.0`
    ... which satisfies dependency `sqlx-core = "^0.6.0"` of package `sqlx v0.6.0`
    ... which satisfies dependency `sqlx = "^0.6"` of package `sui-storage v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-storage` of package `sui-core v0.15.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-core` of package `sui-cost v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-cost` of package `sui-json-rpc v0.0.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-json-rpc` of package `sui-sdk v0.15.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-sdk` of package `movectf-5-sln v0.1.0 (/Volumes/dev/project/web3/sui/movectf/movectf-5-sln)`
versions that meet the requirements `^0.24.1` are: 0.24.2, 0.24.1

the package `libsqlite3-sys` links to the native library `sqlite3`, but it conflicts with a previous package which links to `sqlite3` as well:
package `libsqlite3-sys v0.25.1`
    ... which satisfies dependency `libsqlite3-sys = "^0.25.1"` of package `sqlx-core v0.6.2 (https://github.com/huitseeker/sqlx?branch=update_libsqlite3#fa4613e7)`
    ... which satisfies git dependency `sqlx-core` of package `sqlx v0.6.2 (https://github.com/huitseeker/sqlx?branch=update_libsqlite3#fa4613e7)`
    ... which satisfies git dependency `sqlx` of package `workspace-hack v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `workspace-hack` of package `narwhal-config v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `config` of package `narwhal-consensus v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `consensus` of package `narwhal-executor v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `executor` of package `narwhal-node v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `narwhal-node` of package `sui-core v0.15.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-core` of package `sui-cost v0.1.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-cost` of package `sui-json-rpc v0.0.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-json-rpc` of package `sui-sdk v0.15.0 (https://github.com/MystenLabs/sui#2210e5f6)`
    ... which satisfies git dependency `sui-sdk` of package `movectf-5-sln v0.1.0 (/Volumes/dev/project/web3/sui/movectf/movectf-5-sln)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='libsqlite3-sys' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `libsqlite3-sys` which could resolve this conflict

@amnn amnn added Priority: Critical This task must be completed or something bad will happen e.g. missing a major milestone, major bug devx rust Pull requests that update Rust code rust-sdk sui-devx-oncall Priority: High Very important task, not blocking but potentially delaying milestones or limiting our offering and removed Priority: Critical This task must be completed or something bad will happen e.g. missing a major milestone, major bug labels Nov 8, 2022
@amnn
Copy link
Contributor

amnn commented Nov 8, 2022

Hey @stella3d, got a couple more reports of this issue -- this is going to be blocking anyone that uses the Rust SDK, so fairly urgent -- adding some tags to reflect that.

@amnn
Copy link
Contributor

amnn commented Nov 8, 2022

Another observation from a report on Discord is that it seems to work fine if the Rust SDK is built from source, rather than pulled from crates.io, so this may be a matter of us needing to update our release on crates.

@dougEfresh
Copy link

Is this the commit that's causing all the pain?
huitseeker/sqlx@fa4613e

@dougEfresh
Copy link

This seems to fix the issue

index dd5dee1ab..c808758db 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -111,4 +111,4 @@ workspace-hack = { path = "crates/workspace-hack" }
 # patch sqlx to a version using libsqlite3-sys v0.25.1 or later, see
 # https://github.com/launchbadge/sqlx/pull/2176
 [patch.crates-io]
-sqlx = { git="https://github.com/huitseeker/sqlx", branch="update_libsqlite3" }
+sqlx = { git="https://github.com/huitseeker/sqlx", rev="8fca76065a3a0c46989a4366875aa9b663703001" }

@xs818
Copy link

xs818 commented Nov 9, 2022

So how should I solve this problem?

amnn pushed a commit to amnn/sui that referenced this issue Nov 11, 2022
Sui's dependency on `sqlx` needs to be overridden with a patched
version that uses a more recent version of `libsqlite3-sys`.  The
previous approach used a `patch` configuration in the root
`Cargo.toml`.

This works for builds within this project, but seems to break for
builds that originate from outside the workspace, but depend on one of
the workspace crates.

In this scenario, the patch doesn't apply on the dependency on `sqlx`
in `sui-storage`, so it ends up conflicting with the dependency in
`workspace-hack`.

The most common example of this is someone depending on the Rust
SDK (`sui-sdk`).

This diff ditches the `patch` and sets the dependency override
explicitly on `sui-storage`.

Test Plan:

Sui builds and runs:

```
sui$ cargo build
sui$ cargo simtest
sui$ cargo nextest run
```

Dependents on the Sui SDK build and run, e.g. following the
instructions at https://docs.sui.io/build/rust-sdk succeeds.

Closes MystenLabs#5887
@amnn amnn assigned amnn and unassigned stella3d Nov 11, 2022
amnn added a commit that referenced this issue Nov 11, 2022
Sui's dependency on `sqlx` needs to be overridden with a patched
version that uses a more recent version of `libsqlite3-sys`.  The
previous approach used a `patch` configuration in the root
`Cargo.toml`.

This works for builds within this project, but seems to break for
builds that originate from outside the workspace, but depend on one of
the workspace crates.

In this scenario, the patch doesn't apply on the dependency on `sqlx`
in `sui-storage`, so it ends up conflicting with the dependency in
`workspace-hack`.

The most common example of this is someone depending on the Rust
SDK (`sui-sdk`).

This diff ditches the `patch` and sets the dependency override
explicitly on `sui-storage`.

Test Plan:

Sui builds and runs:

```
sui$ cargo build
sui$ cargo simtest
sui$ cargo nextest run
```

Dependents on the Sui SDK build and run, e.g. following the
instructions at https://docs.sui.io/build/rust-sdk succeeds.

Closes #5887
amnn pushed a commit that referenced this issue Nov 12, 2022
Sui's dependency on `sqlx` needs to be overridden with a patched
version that uses a more recent version of `libsqlite3-sys`.  The
previous approach used a `patch` configuration in the root
`Cargo.toml`.

This works for builds within this project, but seems to break for
builds that originate from outside the workspace, but depend on one of
the workspace crates.

In this scenario, the patch doesn't apply on the dependency on `sqlx`
in `sui-storage`, so it ends up conflicting with the dependency in
`workspace-hack`.

The most common example of this is someone depending on the Rust
SDK (`sui-sdk`).

This diff ditches the `patch` and sets the dependency override
explicitly on `sui-storage`.

Test Plan:

Sui builds and runs:

```
sui$ cargo build
sui$ cargo simtest
sui$ cargo nextest run
```

Dependents on the Sui SDK build and run, e.g. following the
instructions at https://docs.sui.io/build/rust-sdk succeeds.

Closes #5887
@amnn
Copy link
Contributor

amnn commented Nov 12, 2022

The fix has hit devnet branch and I have just confirmed that it's possible to build and run examples using the Rust SDK -- thanks again for your patience everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devx Priority: High Very important task, not blocking but potentially delaying milestones or limiting our offering rust Pull requests that update Rust code rust-sdk sui-devx-oncall
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants