2

to use the init_if_needed feature, i put in my Cargo.toml:

[dependencies]
anchor-lang = { version = "0.25.0", features = [ "init_if_needed" ] }
anchor-spl = "0.24.2"
mpl-token-metadata = { version = "1.2.5", features = [ "no-entrypoint" ] }

and get anchor build error:

error: failed to select a version for `anchor-lang`.

1 Answer 1

3

Hey looks like the dependencies are not correct anchor-lang 0.25 expects also anchor-slp 0.25. Also it should be init-if-needed not init_if_needed try

[dependencies]
anchor-lang = {version = "0.25.0", features = ["init-if-needed"]}
anchor-spl = "0.25.0"
mpl-token-metadata = { version = "1.2.5", features = [ "no-entrypoint" ] }

You can check the correct dependencie here: https://crates.io/crates/anchor-spl/0.25.0/dependencies

7
  • ```versions that meet the requirements ^0.25.0 are: 0.25.0
    – user3438
    Commented Jan 7, 2023 at 18:20
  • how do i update the anchor in the project
    – user3438
    Commented Jan 7, 2023 at 18:22
  • anchor --version anchor-cli 0.24.2
    – user3438
    Commented Jan 7, 2023 at 18:23
  • i guess i stopped where the anchor book said i should uninstall npm and use avm. do they really mean i should entirely remove nodejs from my system? seems wrong.
    – user3438
    Commented Jan 7, 2023 at 18:28
  • 1
    all this was because i wanted the init_if_needed feature. are we advised to make the client take responsibility for creating associated token accounts?
    – user3438
    Commented Jan 7, 2023 at 19:43

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.