It looks like you're facing an issue where the anchor build runs successfully but doesn't generate the IDL file in target/idl, even though there’s no visible error except:
\> Error: Could not build IDL
Given your stack (Anchor 0.31.1, Solana 2.0.25, Rust 1.88.0 on WSL Ubuntu), here are a few suggestions to help troubleshoot:
✅ Things to Double-Check:
1. Correct Program Structure:
Make sure your program has all public instructions properly exported. Anchor requires clear instruction definitions to generate the IDL.
2. Missing #[program] or #[derive(Accounts)] Macros:
If these macros are missing or misconfigured, Anchor might build the binary but fail to generate the IDL.
3. Cargo.toml Validity:
Ensure your lib.rs is set as the crate root in your Cargo manifest.
4. Outdated Anchor CLI Cache:
Sometimes ~/.anchor cache causes issues. Try:
rm -rf ~/.anchor
anchor clean
anchor build
5. Run with Verbose Flag:
Try running with anchor build --verbose to see deeper logs. It might expose where exactly IDL generation fails.
6. IDL Path Issue:
Check whether the IDL is being created but in a different path due to custom project structure.