anchor: error[E0599]: no method named `source_file` found for struct `proc_macro2::Span` in the current scope
I kept getting this error … idk why .
mac silicon rust 1.86 avm 0.31.0
i tried all different installs
error[E0599]: no method named source_file found for struct proc_macro2::Span in the current scope
–> /Users/stevensanborn/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/anchor-syn-0.31.0/src/idl/defined.rs:499:66
|
499 | …n::call_site().source_file().path();
| ^^^^^^^^^^^ method not found in Span
so what fixed it for em was
line 499 … let source_path = proc_macro2::Span::call_site().file();
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 26 (11 by maintainers)
same issue
Also, as a temporary workaround you can do
(and replace
YOUR_PROG_NAMEwith your program name)I tried this solution, however:
error[E0599]: no method named
filefound for reference&proc_macro::Spanin the current scope –> /home/cedro/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/proc-macro2-1.0.95/src/wrapper.rs:465:36 | 465 | Span::Compiler(s) => s.file(), | ^^^^ method not found in&Spanerror[E0599]: no method named
local_filefound for reference&proc_macro::Spanin the current scope –> /home/cedro/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/proc-macro2-1.0.95/src/wrapper.rs:473:36 | 473 | Span::Compiler(s) => s.local_file(), | ^^^^^^^^^^ method not found in&SpanReplace the line with this :
In defined.rs
Line 499
use this
instead of previous line :
Make sure you’re inside your project directory
Make sure you’re using proc-macro2 v0.1.94, not v0.1.95
Yep, you’re correct. Opened a PR for it: https://github.com/solana-foundation/anchor/pull/3663