Yilmaz
Yilmaz

Reputation: 49182

Solana/Anchor error: (yanked dependencies) Failed to obtain package metadata: `cargo metadata` exited with an error: Updating crates.io index

I just set up a new anchor project yesterday, every command runs smoothly.

Today I installed a new anchor project. I run anchor test to see if the project is set up correctly. I am getting this error:

Failed to obtain package metadata: `cargo metadata` exited with an error:     Updating crates.io index
error: failed to select a version for the requirement `anchor-lang = "^0.23.0"`
candidate versions found which didn't match: 0.24.2
location searched: crates.io index
required by package `myAnchorProject v0.1.0 (.../programs/myAnchorProject)`

It is not clear what candidate versions mean. I deleted node_modules and install it with "@project-serum/anchor": "^0.24.2", still same error.

I clear the lib.rs and testing file to see something different, but it still gives the same error.

executing cargo update is giving same error

Upvotes: 0

Views: 3511

Answers (1)

Arjun
Arjun

Reputation: 3793

It's not the problem with dependency in your package.json is due to the use of yanked rust crate anchor-lang

all the other version the 0.24.2 have been yanked so you can't build any cargo project which has yanked dependeny.

refer here https://crates.io/crates/anchor-lang/versions

what you need to do get it working is
go to <your-project-root>/programs/myAnchorProject/cargo.toml.
I'm assuming your program name is myAnchorProject or replace it with your program name.

your current cargo.toml must look something like

...
<other content goes here>
...

[dependencies]
anchor-lang = "^0.23.0"

you need to upgrade the anchor-lang version to 0.24.2 or any other version if available which is not yanked.

so your final cargo.toml should look like

...
<other content goes here>
...

[dependencies]
anchor-lang = "^0.24.2"

Upvotes: 3

Related Questions