coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.66k stars 1.34k forks source link

No implementation for solana_program::pubkey::Pubkey == spl_memo::solana_program::pubkey::Pubkey #3227

Closed hurek closed 1 month ago

hurek commented 1 month ago

Hello! How to fix this error?

error[E0277]: can't compare `solana_program::pubkey::Pubkey` with `spl_memo::solana_program::pubkey::Pubkey`
   --> src/lib.rs:109:62
    |
109 |     if spl_token_program_id != &id() && spl_token_program_id != &spl_token::id() {
    |                                                              ^^ no implementation for `solana_program::pubkey::Pubkey == spl_memo::solana_program::pubkey::Pubkey`
    |
    = help: the trait `PartialEq<spl_memo::solana_program::pubkey::Pubkey>` is not implemented for `solana_program::pubkey::Pubkey`
    = help: the trait `PartialEq` is implemented for `solana_program::pubkey::Pubkey`
    = help: for that trait implementation, expected `solana_program::pubkey::Pubkey`, found `spl_memo::solana_program::pubkey::Pubkey`
    = note: required for `&solana_program::pubkey::Pubkey` to implement `PartialEq<&spl_memo::solana_program::pubkey::Pubkey>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `spl-token-2022` (lib) due to 3 previous errors

My Cargo.toml dependencies

[dependencies]
anchor-lang = "0.30.1"
anchor-spl = "0.30.1"
solana-program = "1.17.3"
acheroncrypto commented 1 month ago

Make sure you don't have Solana v2 in your Cargo.lock and make sure to use spl-memo 4.0.4.

You might have an outdated cache because creating a new project with these dependency requirements should work without a problem.

Also, you can remove solana-program from your Cargo.toml and use it from anchor_lang::solana_program.