0

I'm trying to run a CPI example of Raydium AMM https://github.com/raydium-io/raydium-cpi-example/blob/master/amm-cpi/

All settings are the same as in GitHub repo.

[dependencies]
anchor-lang = "0.29.0"
anchor-spl = "0.29.0"
amm-anchor = { git = "https://github.com/raydium-io/raydium-contract-instructions", package = "amm-anchor" }
solana-program = ">=1.16, <1.18"

It seems that dependencies versions are wrong.

Cargo.lock

[[package]]
name = "solana-program"
version = "1.16.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
...

[[package]]
name = "solana-program"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"

I found that people are playing with versions to solve this problem, but since my experience with Rust and Solana is very low I don't know what versions they are using. And how do they downgrade dependencies that are automatically loaded from other dependencies?

1 Answer 1

0

edit: compiled the amm-cpi example using the versions below with no errors.

anchor-cli 0.28.0
solana-cli 1.17.34 (src:b04a806c; feat:3746964731, client:SolanaLabs)

It's not just what's in your Cargo.toml you might also need to update your lock file,

In a previous project, downgrading one dependency causes a chain reaction where you'll need to downgrade a bunch of other crates which is impossible to know beforehand the ones that'll be affected.

Here is a working lock file https://gist.github.com/jim4067/d251f8b93dd28864c497824ae22e39bd

7
  • I've installed the same environment as yours. Can you please share the command you use to build amm-cpi since whenever I run [anchor build] it updates Cargo.lock file
    – MidesColin
    Commented Oct 2 at 12:41
  • delete the target folder update your lock file with the one in the gist, save and then build
    – Jimii
    Commented Oct 2 at 13:05
  • Thanks for your time, but still there is a problem my@MBP amm-cpi % rm -rf target my@MBP amm-cpi % rm Cargo.lock my@MBP % cp Cargo.lock.Jimii Cargo.lock my@MBP % anchor build error: package num_enum_derive v0.7.3 cannot be built because it requires rustc 1.70.0 or newer, while the currently active rustc version is 1.68.0-dev Either upgrade to rustc 1.70.0 or newer, or use cargo update -p [email protected] --precise ver where ver is the latest version of num_enum_derive supporting rustc 1.68.0-dev You removed num_enum_derive v0.7.3, but the build overwrite Cargo.lock
    – MidesColin
    Commented Oct 2 at 13:14
  • Looks like you are going to update the crates that are causing the issues. Start with cargo update -p [email protected] --precise 0.7.0
    – Jimii
    Commented Oct 2 at 13:33
  • That's because of the requirement of spl-token-2022 which was overwritten in a lock file after anchor build. Can you please share your Cargo.toml file?
    – MidesColin
    Commented Oct 2 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.