Anchor "Error: Unable to read keypair file" in CI
Anchor read the wallet path from Anchor.toml (or the Solana config) and could not open the keypair file there. In CI the default ~/.config/solana/id.json does not exist unless a keypair is generated first.
What this error means
anchor build or anchor test fails with "Error: Unable to read keypair file" and a path such as /home/runner/.config/solana/id.json.
Error: Unable to read keypair file (/home/runner/.config/solana/id.json): No such file or directory (os error 2)Common causes
No keypair exists at the configured path
A fresh runner has no Solana keypair, so the default id.json referenced by the wallet setting is missing.
Anchor.toml points at a path not present in CI
The [provider] wallet value references a file that exists locally but was never created or provided on the runner.
How to fix it
Generate a keypair before building
Create a throwaway keypair at the expected path so Anchor can read it.
solana-keygen new --no-bip39-passphrase -o ~/.config/solana/id.jsonPoint the wallet at an existing file
Set the provider wallet in Anchor.toml to a path you create in CI.
[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"How to prevent it
- Generate a keypair as a setup step before anchor commands.
- Keep the wallet path in Anchor.toml consistent with what CI creates.
- Never commit real keypairs; generate throwaway ones for CI.