I'm trying to build an Anchor program but getting the following error:
anchor build
Compiling jackcoins v0.1.0 (/home/webskitters/projects WS/jackcoins/jackcoins/programs/jackcoins)
Finished release [optimized] target(s) in 2.23s
Compiling jackcoins v0.1.0 (/home/webskitters/projects WS/jackcoins/jackcoins/programs/jackcoins)
error: custom attribute panicked
--> programs/jackcoins/src/lib.rs:8:1
|
8 | #[program]
| ^^^^^^^^^^
|
= help: message: Safety checks failed: Failed to get program path
What I've Verified
Program ID matches in all locations:
declare_id!
in lib.rs matches"BQtK93ZPivZGB3AUH9BBhmgMyvSYxZvzBQH5jR8KHo9f"
- Same ID exists in target/deploy/jackcoins.json
- Anchor.toml has correct program ID
File Structure:
- Program files are in the correct location
- Keypair exists in target/deploy/
- Project follows standard Anchor workspace structure
Attempted Solutions:
- Cleaned and rebuilt project
- Removed target/ and .anchor/ directories
- Verified all file permissions
- Tried building with explicit program name
Environment Details
- Anchor version: anchor-cli 0.29.0
- Solana version: solana-cli 1.18.24 (src:7ba2a0e9; feat:3241752014, client:Agave)
- OS: Ubuntu
- Project: Token program with two SPL tokens
Code
Here's the relevant part of my lib.rs:
use anchor_lang::prelude::*;
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::{self, Mint, Token, TokenAccount};
declare_id!("BQtK93ZPivZGB3AUH9BBhmgMyvSYxZvzBQH5jR8KHo9f");
pub const JCKP_DECIMALS: u8 = 9;
#[program]
pub mod jackcoins {
use super::*;
pub const JCK_DECIMALS: u8 = 9;
const INITIAL_SUPPLY: u64 = 6_000_000_000;
// ... rest of program implementation
}
Questions
- What could be causing this error despite having correct program ID configuration?
- Are there any specific permissions or path requirements I should check?
- Are there any Anchor workspace configuration files I should verify?
Any help would be greatly appreciated!