Skip to content

Instantly share code, notes, and snippets.

@alecchendev
Created November 14, 2021 07:08
Show Gist options
  • Save alecchendev/e0a8a0e07fade542c8c8824d32c795aa to your computer and use it in GitHub Desktop.
Save alecchendev/e0a8a0e07fade542c8c8824d32c795aa to your computer and use it in GitHub Desktop.
Solana Installation Guide for M1 Without Rosetta

Solana Installation Guide for M1 Without Rosetta (v1.8.2)

Figured out how to install solana on M1 without Rosetta and I haven't found a totally complete guide elsewhere so here you go:

NOTE: Haven't done exhaustive development testing but most fundamental stuff seems to work - test validator, airdrop, transactions, deployment

Install rust.

curl --proto '=https' --tlsv1.2 [https://sh.rustup.rs](https://sh.rustup.rs/) -sSf | sh

Download solana from source.

git clone [https://github.com/solana-labs/solana.git/](https://github.com/solana-labs/solana.git/)

Cd into the folder and git checkout to the branch with whatever version you want. I've only tested this out with the latest release - v1.8.2.

cd solana
git checkout v1.8.2

Next step is to install solana with the following command. I'm just gonna tell you right now this is probably not going to work the first time.

./scripts/cargo-install-all.sh .

You'll probably run into some error like greadlink: command not found in which you should install coreutils via

brew install coreutils

If you don't have brew, install brew.

/bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh](https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh))"

If you try to run the install script, maybe you'll be lucky and it'll work, but if you're me then you'll run into a problem regarding openssl in which you should install via

brew install openssl@1.1

At the end of this it'll give you a little script to export openssl to your PATH. I did this but I'm pretty sure you don't have to because I remember seeing some terminal output saying rust just looks for it anyway.

Once again maybe if you're lucky the install script might work now, but probably not. You'll get some error saying smth smth linking, smth smth. Create a file at ~/.cargo/config and paste this

[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

You probably don't need the first section because we're doing this without Rosetta, but I copied this from a Rosetta guide and I haven't tested the installation process without that section so yeah.

Ok now try that install script from before and it should work.

./scripts/cargo-install-all.sh .

After that remember to add the solana binaries to your PATH. From the current directory this should work. (echo >> ~/.zshrc to make it persist).

export PATH=$PWD/bin:$PATH

Extra: when you're working with anchor, you'll have to slightly modify your commands because of the lack of support of M1. anchor test will try to run its own test validator, but it won't work. Solution: run your own validator with

solana-test-validator --no-bpf-jit

and then run anchor test using that with

anchor test --skip-local-validator

That's it! Hope that helps.

NOTE: This is mostly just a combination of two other M1 guides, real credit go to these resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment