11

I am trying to start solana-test-validator, but it closes unexpectedly with blockstore error.

Error: failed to start validator: Failed to create ledger at test-ledger: blockstore error

How can I fix this?

8
  • Do you start validator as ./validator/solana-test-validator? Commented Nov 22, 2022 at 10:32
  • Yes, but i also tried different locations. Commented Nov 22, 2022 at 10:43
  • Do you have Rosetta installed btw? I cannot reproduce your issue on my mac (v12 and Rosetta is intalled) Commented Nov 22, 2022 at 15:40
  • Yep, rosetta is installed :( Commented Nov 22, 2022 at 18:22
  • I guess the problem is with macos v13 since for v12 it works. But I don't know how to check it out without installing Commented Nov 23, 2022 at 16:26

5 Answers 5

29

it seems like something is not right with the tar version in Mac OS 13. I could fix the issue by replacing tar with a homebrew gnu version:

brew install gnu-tar
# Put this in ~/.zshrc 
export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"

Hope that helps.

There is an open GitHub issue at Solana Labs to make the install experience better for macOS users with the default BSD tar installed.

5
  • this fixed it for me!!
    – Dev Bharel
    Commented Dec 14, 2022 at 5:27
  • I have gnu-tar in a different location. After adding export PATH="/usr/local/Cellar/gnu-tar/1.34_1/libexec/gnubin:$PATH" to ~/.zshrc it was fixed.
    – channa ly
    Commented Dec 22, 2022 at 15:45
  • This also fixed it for me on MacOS Ventura 13.3.1 M1 with solana-cli 1.14.18 and rustc pinned to 1.65.0 using a rust-toolchain.toml Commented May 25, 2023 at 23:27
  • this fixed my problem though the error log is different: 'Error: failed to start validator: Failed to create ledger at test-ledger: io error: Error checking to unpack genesis archive: Archive error: extra entry found: "._genesis.bin" Regular'
    – DiveInto
    Commented Mar 23 at 9:47
  • @diveinto Yep, that's the same cause. I'd originally added a bunch of detail to this answer but have now moved it to a separate answer below. Solana CLI (and therefore Anchor) aren't ready to use BSD tar, there's an open GitHub issue to fix it, my answer has more details.
    – mikemaccana
    Commented May 30 at 19:56
3

Note: you might also have this error occur when you run anchor test:

Unable to get latest blockhash. Test validator does not look started. Check ".anchor/test-ledger/test-ledger-log.txt" for errors. Consider increasing [test.startup_wait] in Anchor.toml.

Looking inside .anchor/test-ledger/test-ledger-log.txt, you will see:

Error checking to unpack genesis archive: Archive error: extra entry found: "._genesis.bin" Regular

The cause and solution

There are multiple versions of the 'tape archiver' (tar) program.

MacOS comes with BSD tar by default:

% tar --help | grep bsdtar
tar(bsdtar): manipulate archive files

Which is a less popular version of tar than the GNU tar. solana-test-validator expects GNU tar.

There is an issue to resolve the GNU tar dependendency. In the meantime, you can work around this issue by replacing BSD tar with a GNU version.

If you haven't installed homebrew, do that first. Then run:

brew install gnu-tar
# Put this in ~/.zshrc 
export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"

You will now have BSD tar installed.

And then re-run solana-test-validator

2

I had the same problem

solana-test-validator --reset

worked for me

2

If you're facing the same error even after installing gnu-tar. Try removing the test-ledger folder rm -rf test-ledger and try again.

2

This is because the BSD tar program is not compatible with the GNU tar program.

To fix it: you need to install and export the executable path of your GNU tar program in your .zshrc file.

Mac with Apple Silicon

brew install gnu-tar
# Put this in ~/.zshrc 
export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"

Intel-based Mac

brew install gnu-tar
# Put this in ~/.zshrc 
export PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"

the only reason there are separate exports for intel-based macs and macs with apple silicon is that, by default, homebrew executables are stored at different locations for macs with respective chipset.

1
  • Was quite helpful
    – Codertjay
    Commented Oct 3 at 7:20

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.