0

got an dependency issue when trying to build anchor

My anchor version:

>>> anchor --version
anchor-cli 0.24.1

I've initialized project:

anchor init solana-escrow-anchor

Then, move into directory to compile this:

>>> anchor build    
BPF SDK: /Users/n.duginets/.local/share/solana/install/releases/stable-616d8d67978c325087cc5a9f33307f54eee48b6e/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /Users/n.duginets/IdeaProjects/solana-escrow-anchor/programs/solana-escrow-anchor/Cargo.toml
workspace: /Users/n.duginets/IdeaProjects/solana-escrow-anchor/Cargo.toml
    Updating crates.io index
error: failed to select a version for the requirement `aho-corasick = "^1.0.0"`
candidate versions found which didn't match: 0.7.20, 0.7.19, 0.7.18, ...
location searched: crates.io index
required by package `regex v1.8.1`
    ... which satisfies dependency `regex = "^1.0"` (locked to 1.8.1) of package `anchor-attribute-access-control v0.27.0`
    ... which satisfies dependency `anchor-attribute-access-control = "^0.27.0"` (locked to 0.27.0) of package `anchor-lang v0.27.0`
    ... which satisfies dependency `anchor-lang = "^0.27.0"` (locked to 0.27.0) of package `solana-escrow-anchor v0.1.0 (/Users/n.duginets/IdeaProjects/solana-escrow-anchor/programs/solana-escrow-anchor)`

And got this strange error.

How can I fix this?

1 Answer 1

-1

According to the error notice, there is a dependency issue with the version of the "aho-corasick" crate. The version required by the "regex" crate and several of the dependencies of the "solana-escrow-anchor" project are incompatible.

You can try one of the following fixes to resolve this problem:

  • List item: The "solana-escrow-anchor" project's Cargo.toml file should be modified to match the version requirement of the "regex" crate for the "aho-corasick" crate. To ensure compatibility with the most recent version of the "regex" crate, you can try altering the "1.0.0" requirement to "0.7.0." Run the "anchor build" command once more after that.

  • List item: Update the version of the "regex" crate to one that is compatible with the version of "aho-corasick" required by the other dependencies if altering the version requirement of the "aho-corasick" crate is not possible. Change the "regex" crate's version requirement in the "solana-escrow-anchor" project's Cargo.toml file to do this. Run the "anchor build" command once more after that.

  • List item: Utilising a dependency resolver tool, such as "cargo-edit" or "cargo-tree" to examine the dependency tree and identify the problem's underlying causes, is another option. These tools can show you which versions of the dependencies are incompatible and offer a potential fix.

3
  • I've tried all of these items, still the same error Commented May 1, 2023 at 22:34
  • 1
    resolved with updating anchor to 0.27.0 and solana to 1.15.2 Commented May 2, 2023 at 10:14
  • Stop copying chatGPT as answers Commented May 5, 2023 at 6:09

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.