Skip to content

Dependency conflict in generated the rust client (anchor-lang and solana-program@~2.1) #114

@cf

Description

@cf

Description of Issue

The rust client depends on [email protected] and solana-program@~2.1, and this leads to a dependency conflict as a result of anchor-lang's dependency on solana-program 1.x.

How to reproduce

pnpm create solana-program --client rust --org acme --default --shank shank-example-with-rust-client
cd shank-example-with-rust-client
pnpm install
pnpm generate
# NOTE: all of the commands above run successfully
pnpm clients:rust:test

Error Output:

shank-example-with-rust-client pnpm clients:rust:test


> @ clients:rust:test /Users/carter/sol11/solapp/shank-example-with-rust-client
> zx ./scripts/client/test-rust.mjs

$ cd /Users/carter/sol11/solapp/shank-example-with-rust-client/clients/rust
$ SBF_OUT_DIR=/Users/carter/sol11/solapp/shank-example-with-rust-client/target/deploy cargo test --features "test-sbf" 
    Updating crates.io index
error: failed to select a version for `curve25519-dalek`.
    ... required by package `solana-program v1.16.0`
    ... which satisfies dependency `solana-program = "^1.16"` of package `anchor-lang v0.30.0`
    ... which satisfies dependency `anchor-lang = "^0.30.0"` of package `acme-shank-example-with-rust-client-client v0.0.0 (/Users/carter/sol11/solapp/shank-example-with-rust-client/clients/rust)`
versions that meet the requirements `^3.2.1` are: 3.2.1

all possible versions conflict with previously selected packages.

  previously selected package `curve25519-dalek v3.0.0`
    ... which satisfies dependency `curve25519-dalek = "^3"` of package `ed25519-dalek v1.0.1`
    ... which satisfies dependency `ed25519-dalek = "=1.0.1"` of package `solana-sdk v2.1.0`
    ... which satisfies dependency `solana-sdk = "~2.1"` of package `acme-shank-example-with-rust-client-client v0.0.0 (/Users/carter/sol11/solapp/shank-example-with-rust-client/clients/rust)`

failed to select a version for `curve25519-dalek` which could resolve this conflict
Error:     Updating crates.io index
error: failed to select a version for `curve25519-dalek`.
    ... required by package `solana-program v1.16.0`
    ... which satisfies dependency `solana-program = "^1.16"` of package `anchor-lang v0.30.0`
    ... which satisfies dependency `anchor-lang = "^0.30.0"` of package `acme-shank-example-with-rust-client-client v0.0.0 (/Users/carter/sol11/solapp/shank-example-with-rust-client/clients/rust)`
versions that meet the requirements `^3.2.1` are: 3.2.1

all possible versions conflict with previously selected packages.

  previously selected package `curve25519-dalek v3.0.0`
    ... which satisfies dependency `curve25519-dalek = "^3"` of package `ed25519-dalek v1.0.1`
    ... which satisfies dependency `ed25519-dalek = "=1.0.1"` of package `solana-sdk v2.1.0`
    ... which satisfies dependency `solana-sdk = "~2.1"` of package `acme-shank-example-with-rust-client-client v0.0.0 (/Users/carter/sol11/solapp/shank-example-with-rust-client/clients/rust)`

failed to select a version for `curve25519-dalek` which could resolve this conflict
    at file:///Users/carter/sol11/solapp/shank-example-with-rust-client/scripts/client/test-rust.mjs:17:10
    exit code: 101
 ELIFECYCLE  Command failed with exit code 1.

How to fix

Downgrade solana-program (+ solana-program-test, etc.) to version ^1.18.26, and upgrade anchor-lang to version ^0.30.1
See: https://github.com/create-solana-program/shank-example-with-rust-client/pull/1/files

diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml
index f1b090e..6d04d4d 100644
--- a/clients/rust/Cargo.toml
+++ b/clients/rust/Cargo.toml
@@ -13,16 +13,16 @@ test-sbf = []
 serde = ["dep:serde", "dep:serde_with"]
 
 [dependencies]
-anchor-lang = { version = "0.30.0", optional = true }
+anchor-lang = { version = "0.30.1", optional = true }
 borsh = "^0.10"
 num-derive = "^0.3"
 num-traits = "^0.2"
 serde = { version = "^1.0", features = ["derive"], optional = true }
 serde_with = { version = "^3.0", optional = true }
-solana-program = "~2.1"
+solana-program = "^1.18.26"
 thiserror = "^1.0"
 
 [dev-dependencies]
 assert_matches = "1.5.0"
-solana-program-test = "~2.1"
-solana-sdk = "~2.1"
+solana-program-test = "^1.18.26"
+solana-sdk = "^1.18.26"
diff --git a/program/Cargo.toml b/program/Cargo.toml
index b3cfc6f..876dab4 100644
--- a/program/Cargo.toml
+++ b/program/Cargo.toml
@@ -19,5 +19,5 @@ borsh = "^0.10"
 shank = "^0.4.2"
 num-derive = "^0.3"
 num-traits = "^0.2"
-solana-program = "~2.1"
+solana-program = "^1.18.26"
 thiserror = "^1.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions