coral-xyz / anchor

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

build breaks with anchor-spl v0.30.1 #3136

Closed gxxcastillo closed 3 months ago

gxxcastillo commented 3 months ago

Summary

As of last night, anchor build breaks with anchor-spl v0.30.1.

Also, noob question: It says I'm using the nightly build, how do I use the previous build?

Details

As of last night I've tried building a few different projects that were previously building and I'm getting this error. The printout is pretty long so I've truncated it...

Note, I had to delete my existing /target folder in order to reproduce.

Compiling anchor-spl v0.30.1
error: expected `::`, found `:`
 --> src/token.rs:1:59
  |
1 | use anchor_lang::solana_program::account_info::AccountInfo:mint_to;
  |                                                           ^ help: use double colon
  |
  = note: import paths are delimited using `::`

error[E0432]: unresolved import `anchor_lang::solana_program::account_info::AccountInfo`
 --> src/token.rs:1:48
  |
1 | use anchor_lang::solana_program::account_info::AccountInfo:mint_to;
  |                                                ^^^^^^^^^^^ `AccountInfo` is a struct, not a module

error[E0412]: cannot find type `AccountInfo` in this scope
   --> src/token.rs:340:15
    |
340 |     pub from: AccountInfo<'info>,
    |               ^^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
1   + use anchor_lang::prelude::AccountInfo;
    |

error[E0412]: cannot find type `AccountInfo` in this scope
   --> src/token.rs:341:13
    |
341 |     pub to: AccountInfo<'info>,
    |             ^^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
1   + use anchor_lang::prelude::AccountInfo;
    |

error[E0412]: cannot find type `AccountInfo` in this scope
   --> src/token.rs:342:20
    |
342 |     pub authority: AccountInfo<'info>,
    |                    ^^^^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
1   + use anchor_lang::prelude::AccountInfo;
    |

error[E0412]: cannot find type `AccountInfo` in this scope
   --> src/token.rs:338:10
    |
338 | #[derive(Accounts)]
    |          ^^^^^^^^ not found in this scope
    |
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
    |
...
acheroncrypto commented 3 months ago

It looks like your local cache somehow got corrupted because we wouldn't be able to release the anchor-spl crate if we used something like

use anchor_lang::solana_program::account_info::AccountInfo:mint_to;

You can see the published source that's tagged on GitHub here:

https://github.com/coral-xyz/anchor/blob/e6d7dafe12da661a36ad1b4f3b5970e8986e5321/spl/src/token.rs#L1

I'd recommend removing the anchor-spl from your cargo cache located in ~/.cargo/registry.

gxxcastillo commented 3 months ago

I'm still seeing the same errors after deleting all of ~/.cargo/registry

gxxcastillo commented 3 months ago

I haven't made any changes to my rust setup since last week and I've been running builds just fine up until last night.

➜ rustc --version
rustc 1.79.0 (129f3b996 2024-06-10)
➜ cargo --version
cargo 1.79.0 (ffa9cf99a 2024-06-03)
➜ anchor --version
anchor-cli 0.30.1
gxxcastillo commented 3 months ago

NM, fixed. Not sure what happened but I was able to resolve the issue with:

> cargo update
> anchor clean
> anchor build

apologies for the trouble!