I have a project that fails with Unable to read keypair file when I run anchor test:

 anchor test
    Finished release [optimized] target(s) in 0.09s

Found a 'test' script in the Anchor.toml. Running it as a test suite!

Running test suite: "/Users/mikemaccana/Code/solana/anchor-movie-review-program/Anchor.toml"

Error: Unable to read keypair file

The error doesn't include the name of the keypair file it is looking for but I have seen this issue before when ~/.config/solana/id.json doesn't exist.


  • ~/.config/solana/id.json does exist
  • All other projects on my system work. I can make the error occur on demand for other projects by renaming ~/.config/solana/id.json, so it's very clear that other projects are using ~/.config/solana/id.json, just not this one.

I did try and use strace to see the name of the file it's accessing, but strace and dtrace are hard to use on a mac without disabling System Integrity Protection.

1 Answer 1


Answering my own question to help others:

The wallet is determined by the provider.wallet setting in Anchor.toml. In the case of this program, the git repo had the macOS username of the program's creator in it's Anchor.toml:

cluster = "Localnet"
wallet = "/Users/someone-else/.config/solana/id.json"

wallet must be included (there is no default value), but you can make a project use the current user's wallet using ~/.config/solana/id.json.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.