solana-labs / example-helloworld

Hello world on Solana
MIT License
898 stars 867 forks source link

solana-test-validator Library not loaded error #200

Closed interdailytop19 closed 2 years ago

interdailytop19 commented 3 years ago

m1 chip macOS 11.3.1 node version v14.16.1

when start solana-test-validator

dyld: Library not loaded: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib
  Referenced from: /Users/123/.local/share/solana/install/active_release/bin/solana-test-validator
  Reason: image not found
zsh: abort      solana-test-validator

google searched this thread: https://stackoverflow.com/questions/59006602/dyld-library-not-loaded-usr-local-opt-openssl-lib-libssl-1-0-0-dylib

but can't switch openssl vserion

Error: Unknown command: switch

tried different node versions tried reinstall xcode and brew with no luck

which openssl
/usr/bin/openssl
cd /usr/local/opt/openssl@1.1
cd: no such file or directory: /usr/local/opt/openssl@1.1
MohitKumar1991 commented 3 years ago

I can confirm this error on Mac M1. Even after linking the right library the message I get is

Referenced from: /Users/mohitkumar/.local/share/solana/install/active_release/bin/solana-test-validator Reason: no suitable image found. Did find: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib: mach-o, but wrong architecture /opt/homebrew/Cellar/openssl@1.1/1.1.1k/lib/libssl.1.1.dylib: mach-o, but wrong architecture

It looks like M1 is not supported right now. can you guys put instructions on how to compile for M1 ?

astronaute77 commented 3 years ago

Linking openssl can be achieved with: echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

But then you’ll run into this one: https://github.com/solana-labs/solana/issues/17406

MohitKumar1991 commented 3 years ago

Yes. Just wanted to post here for anyone trying.

I tried to install docker and then get the solanalabs/rust image and install the cli on it. But there is a problem with AVX support there as well. The message I get is this machine does not support AVX. Apparently there is no way to run solana without CUDA.

Anyway if someone finds a way to run solana locally on a Mac M1 please let me know. I am able to run it on older Mac without any problem.

interdailytop19 commented 3 years ago

solana-labs/solana#17222

jstarry commented 3 years ago

@MohitKumar1991 can you try installing Rosetta on your M1 mac and see if that resolves your issue? If so, it would be helpful to have some instructions for other users with this issue written up in a new PR if you have time

interdailytop19 commented 3 years ago

installing Rosetta didn't resolves my issue, got illegal hardware instruction error

fanatid commented 3 years ago

I was able to run solana-test-validator for helloword example, but with compiled binary from source code with small changes:

- Checkout to `v1.7.1`
- Comment line with `spl-token-cli` installation, because it's not compilable right now due to `ring` crate: https://github.com/solana-labs/solana/blob/v1.7.1/scripts/cargo-install-all.sh#L135
- Cherry-pick code from https://github.com/solana-labs/solana/pull/17632

but still not able to deploy program to validator:

Error: Deploying program failed: unable to confirm transaction. This can happen in situations such as transaction expiration and insufficient fee-payer funds
pra-dan commented 3 years ago

@MohitKumar1991 what did you go with ? Any solution till now ?

yenicelik commented 3 years ago

same issue here, Mac M1. any ideas how to circumvene?

nhamthanh commented 3 years ago

@MohitKumar1991

Did find: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib: mach-o, but wrong architecture /opt/homebrew/Cellar/openssl@1.1/1.1.1k/lib/libssl.1.1.dylib: mach-o, but wrong architecture

-> Just install rosetta 2 and new ur terminal with rosetta. Then install Homebrew, openssl on rosetta terminal. It will run ok

But you will get new error like this Ledger location: test-ledger Log: test-ledger/validator.log ⠙ Initializing... zsh: illegal hardware instruction solana-test-validator

By the way, I think this issue and issue #236 and illegal hardware instruction is same root cause ( solana is not work on ARM structure although using rosetta) I think Maintaining should make openSSL and solana support structure ARM on M1 instead using rosetta because it make too much compiles errors.

t-nelson commented 3 years ago

The macos release binaries are not suitable for M1 silicon in any configuration as they are built for x86_64 arch with AVX and AVX2 extensions available. Building them from scratch under Rosetta is the workaround for now. See https://github.com/solana-labs/solana/blob/master/README.md#building

evilboyajay commented 3 years ago

You can set your config URL to https://api.devnet.solana.com solana config set --url https://api.devnet.solana.com

Mihail-Madzharov commented 3 years ago

Is someone working on fix for M1?

acamill commented 3 years ago

Still the same issue here. Currently my workaround is to dev against devnet, not optimal but works...

pierreneter commented 3 years ago

@Mihail-Madzharov

Is someone working on fix for M1?

You can try with this guide of jaso from discord(https://discord.com/channels/428295358100013066/517163444747894795/884262811260289054):

I ran into trouble trying to build solana binaries with Apple M1 chip so I will post what made it work for me here (and anyone can always DM me if you run into trouble):

  1. Make sure you install rosetta and then install homebrew with a shell that is using rosetta: https://5balloons.info/correct-way-to-install-and-use-homebrew-on-m1-macs/
    1. Make sure you also install rust/cargo/rustup inside that rosetta shell as well bc it will target x86_64 instead of aarch64
    2. then install solana by following the "Build From Source" at the bottom of: https://docs.solana.com/cli/install-solana-cli-tools you may run into an issue with openssl, if you do, then brew install openssl (once again inside the rosetta shell)
acamill commented 3 years ago

Thanks will try tonight. Other option is to build validatir from source, but I've issue making it work with the anchor test calls. Else I can run the 1.7.11 test validator built from source on my m1

acamill commented 3 years ago

I am so thanksful for you taking the time to point me to these resources, merci @pierreneter

acamill commented 3 years ago

And now IDK why but my rosetta terminal refuse to use the correct prefix, so installations still fail :/

ld: warning: ignoring file /opt/homebrew/opt/openssl@1.1/lib/libssl.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

I saw that prefix cannot be forced, but so solana is picking the wrong openssl build and arch is invalid. Too much time, back to linux for now

acamill commented 3 years ago

Got these additional informations about a full reinstall for Discord, if it can help anyone image

astronaute77 commented 3 years ago

Someone needs to start working on full M1 compatibility, Apple is only making those from now on. It makes no sense to rely on Roseta today unless it is a temporary workaround (no one confirmed it is the case).

acamill commented 3 years ago

I agree, but I need to build, so I do what it takes Seems it's up for grab, if you have the spirit for it 😏

yangli-io commented 2 years ago

Yeah didn't really work for me, I hope this gets fixed soon

acamill commented 2 years ago

It does work, you need to nuke any brew or other things installed for the M1, and to reinstall the whole stack with a rosetta term. Including solana built from source it's not straight forward, but it works

ch3njust1n commented 2 years ago

I'm using a rosetta terminal and still getting this issue. :/

acamill commented 2 years ago

It does work, I have done it on several computers, a few times. You really need to wipe everything from brew upward

nicoestrada commented 2 years ago

Nuking the brew already configured on the m1 and reinstalling the stack with a rosetta term not ideal for me, wondering if anyone knows there will be a proposed alternate solution in the works?

nicoestrada commented 2 years ago

Got it to work by just cloning terminal with rosetta and starting from scratch that route...

mrwatts88 commented 2 years ago

Good article on Rosetta workaround: https://dev.to/nickgarfield/how-to-install-solana-dev-tools-on-an-m1-mac-kfn

aronchick commented 2 years ago

I get that this is an M1 problem, but literally anyone doing default install is going to be presented with this issue. I'm not sure why this is being closed.

Further, Rosetta was always designed to be a work around/temporary. Rosetta isn't even supported in all regions - https://9to5mac.com/2021/03/02/apple-may-disable-rosetta-2-on-m1-macs-in-some-regions-macos-11-3-code-suggests/

I get that this is not the top priority, but it makes it quite difficult to support the Solana ecosystem.

gh-osama commented 2 years ago

The solana-cli works on M1 now except the validator needs a recompile for M1. The edit/compile explained here worked.

Ian-Bright commented 2 years ago

@jstarry Not sure why you closed this issue. A valid solution was not provided and it seems this will become evermore problematic as Apple will only be producing laptops with M1 chips.

mb-mb commented 2 years ago

same problem here

CryptoWizardsNet commented 2 years ago

Ive tried everything multiple times. My computer is just throttling now due to the number of attempts. A full clean/reformat of the system might do it, but honestly that's ridiculous.

mariesco commented 1 year ago

For me work this:

  1. First install Solana from brew or with curl.
  2. Clone the repository of solana.
  3. git checkout v1.9.4.
  4. cargo build --release --bin solana-test-validator
  5. cd validator
  6. ./solana-test-validator
amirvenus commented 2 months ago

For me work this:

  1. First install Solana from brew or with curl.
  2. Clone the repository of solana.
  3. git checkout v1.9.4.
  4. cargo build --release --bin solana-test-validator
  5. cd validator
  6. ./solana-test-validator

It fails for me with the following output:

   Compiling unreachable v1.0.0
   Compiling bstr v0.2.17
   Compiling foreign-types v0.3.2
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
   --> sdk/program/src/account_info.rs:153:13
    |
153 | /             std::ptr::write_volatile(
154 | |                 self.owner as *const Pubkey as *mut [u8; 32],
155 | |                 new_owner.to_bytes(),
156 | |             );
    | |_____________^
    |
    = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
    = note: `#[deny(invalid_reference_casting)]` on by default

error: could not compile `solana-program` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...