2

I create a anchor project that only depend on anchor-lang = "0.29.0" in Cargo.toml One thing I can't understand is that after cargo add or update, the 'solana-program' version inside Cargo.lock file is v1.18.3, this is the question. As I saw the anchor-lang's 'Cargo.toml' use dep as:

[dependencies.solana-program]
version = "1.16"

Is there any way to show how cargo resolve and use v1.18.3 ?

Thanks

1 Answer 1

3

cargo, the Rust package manager, uses Semantic Versioning (SemVer) when deciding which version of the dependency to install.

anchor-lang uses the following version requirement for solana-program crate:

solana-program = "1.16"

For SemVer, this means >= 1.16.0, < 2.0.0, and because cargo resolves to the latest compatible version by default, new installations (without a lock file) currently resolve to the 1.18.3 version.

2
  • Thanks. Your conclusion is correct. I just wrote simple demo to prove it. But the SemVer link your provided do not have detail on on how does "x.y" resolved. Cargo may use it own SemVer flavor. I will do more search to found Cargo specified document on SemVer. Commented Mar 3 at 15:28
  • Just a note for others experiencing this issue that there is a bug filed at github.com/solana-labs/solana/issues/32503 to make solana-program to make solana-program correctly use semver and fix this issue.
    – mikemaccana
    Commented May 3 at 14:58

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.