Wojciech Jeleń
Wojciech Jeleń

Reputation: 399

Failed to start solana-test-validator on Apple Silicon M1

When I try to run solana-test-validator , I get the following terminal output with error:

--faucet-sol argument ignored, ledger already exists
Ledger location: test-ledger
Log: test-ledger/validator.log
Error: failed to start validator: TestValidator startup failed: Custom { kind: Other, error: "Discover failed" }

My solana config get:

Config File: /Users/wojciech/.config/solana/cli/config.yml
RPC URL: http://localhost:8899
WebSocket URL: ws://localhost:8900/ (computed)
Keypair Path: /Users/wojciech/.config/solana/id.json
Commitment: confirmed

rustc versionL rustc 1.58.0 (02072b482 2022-01-11)

I've tried with both installation ways: recommended- via curl and I have also built and installed from source (both ver 1.9.4). No errors or warnings during both installations.

Upvotes: 0

Views: 1819

Answers (2)

rathink1
rathink1

Reputation: 1

You can try checking the logs at test-ledger/validator.log. Usually it will be some ERROR message like

re^[[0m^[[38;5;8m]^[[0m On mac OS you may need to run |sudo launchctl limit maxfiles 500000 500000| first

Running sudo launchctl limit maxfiles 500000 500000 fixes it in many cases.

Upvotes: 0

Scott
Scott

Reputation: 21

Build from source allows you functionality for both solana-test-validator and allows one to utilize the anchor environment to build and test. You can use cargo build and cargo test but that will not populate the target/idl with the proper artifacts needed.

Note: You will need to run the command solana-test-validator from within your project directory once the symlink to the path is set. So if you're project is hello-world, you run the test-validator from there, not the Solana source files.

In the below instructions, build-source refers to the Source code (tar.gz) file you download to follow the instructions to build from source in order to install the Solana CLI tools found here: https://docs.solana.com/cli/install-solana-cli-tools#build-from-source

Go to sdk/cargo-build-bpf from the build-source project root. From there, run the following:

cargo install --path .

Verify the path created by opening a separate terminal and navigating to ~/.cargo/bin. List the contents of bin with:

ln -l .

You will either see SDK or cargo-build-bpf. On my Mac M1 chip running Monterey, I found the path to end with the latter.

So, On an apple M1 chip the cargo-build-bpf program is installed to the path ~/.cargo/bin/cargo-build-bpf. This will allow you to run commands like anchor build successfully in your local project root once you create a symlink from it to the path in your Solana source code/bin/sdk folder.

In a separate terminal navigate to ~/.cargo/bin and create a symlink to the sdk folder in the build-source project’s bin folder, like this:

ln -s solana-1.9.2/bin/sdk ~/.cargo/bin/cargo-build-bpf

Replace solana-1.9.2 with the build-source code you downloaded earlier.

Upvotes: 2

Related Questions