Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple M1 support #535

Open
fade2black opened this issue Jan 7, 2024 · 12 comments
Open

Apple M1 support #535

fade2black opened this issue Jan 7, 2024 · 12 comments

Comments

@fade2black
Copy link

fade2black commented Jan 7, 2024

My MacOS is Apple M1 chipset, with Sonoma 14.2

I installed protobuf using brew install protobuf and tried to compile to compile an empty hello, world! project with raft crate included. The compilation failed with

   Compiling raft-proto v0.7.0
error: failed to run custom build command for `raft-proto v0.7.0`

Caused by:
  process didn't exit successfully: `/Users/bayram/Projects/Rust/hello-raft/target/debug/build/raft-proto-c2bff7cf48736de7/build-script-build` (exit status: 101)
  --- stdout
  The system `protoc` version mismatch, require >= 3.1.0, got 25.1.x, fallback to the bundled `protoc`

  --- stderr
  thread 'main' panicked at /Users/bayram/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protobuf-build-0.14.1/src/protobuf_impl.rs:35:14:
  No suitable `protoc` (>= 3.1.0) found in PATH
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I guess it is related to these lines inside protobuf_impl.rs

let protoc_bin_name = match (env::consts::OS, env::consts::ARCH) {
        ("linux", "x86") => "protoc-linux-x86_32",
        ("linux", "x86_64") => "protoc-linux-x86_64",
        ("linux", "aarch64") => "protoc-linux-aarch_64",
        ("linux", "powerpc64") => "protoc-linux-ppcle_64",
        ("macos", "x86_64") => "protoc-osx-x86_64",
        ("windows", _) => "protoc-win32.exe",
        _ => panic!("No suitable `protoc` (>= 3.1.0) found in PATH"),
    };

Or does it support M1 chipset and am I missing something?

@BusyJay
Copy link
Member

BusyJay commented Jan 8, 2024

It's just having problem recognizing version "25.1.x". As a workaround, you can put an outdated protoc in PATH.

@fade2black
Copy link
Author

@BusyJay Successfully built. Thank you.

@fade2black
Copy link
Author

@BusyJay I managed to compile and run the example with a single node, however with 5 nodes it fails with:

Compiling hello-raft v0.1.0 (/Users/bayram/Projects/Rust/hello-raft)
error[E0599]: no method named `merge_from_bytes` found for struct `raft::prelude::ConfChange` in the current scope
   --> src/main.rs:291:24
    |
291 |                     cc.merge_from_bytes(&entry.data).unwrap();
    |                        ^^^^^^^^^^^^^^^^ method not found in `ConfChange`
    |
   ::: /Users/bayram/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protobuf-2.28.0/src/message.rs:94:8
    |
94  |     fn merge_from_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()> {
    |        ---------------- the method is available for `raft::prelude::ConfChange` here
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
7   + use protobuf::message::Message;
    |

warning: unused import: `protobuf::Message`
  --> src/main.rs:14:5
   |
14 | use protobuf::Message as PbMessage;
   |     ^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `hello-raft` (bin "hello-raft") generated 1 warning
error: could not compile `hello-raft` (bin "hello-raft") due to previous error; 1 warning emitted

This is my Cargo.toml

[package]
name = "hello-raft"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bytes = "1.5.0"
protobuf = "3.3.0"
raft = "0.7.0"
raft-proto = "0.7.0"
regex = "1.10.2"
slog = "2.7.0"
slog-async = "2.8.0"
slog-envlogger = "2.2.0"
slog-stdlog = "4.1.1"
slog-term = "2.9.0"

Any idea how to fix it?

@BusyJay
Copy link
Member

BusyJay commented Jan 8, 2024

Currently, raft-rs uses protobuf 2.x.

@fade2black
Copy link
Author

@BusyJay Thank you. Worked.

@fade2black
Copy link
Author

fade2black commented Jan 8, 2024

@BusyJay I want to play around with the crate. Do you have sort of community or a place where I could ask questions if I have ones regarding usage of the crate or internals of the crate?

@BusyJay
Copy link
Member

BusyJay commented Jan 11, 2024

Both issues and github discussions are OK.

@dviejokfs
Copy link

Hi! I'm facing the same problem, I tried downgrading to version 3 but still it happens, is there any other solution?

@BusyJay
Copy link
Member

BusyJay commented Nov 13, 2024

This issue includes several problems, what's the exact error did you meet? Maybe we should create a new issue to discuss the problem more specifically.

@dviejokfs
Copy link

@BusyJay
I'm getting the protobuf error:

Caused by:
  process didn't exit successfully: `/Users/davidviejo/poc/rust-raft-poc/target/debug/build/raft-proto-d85050faeb1cbc6b/build-script-build` (exit status: 101)
  --- stdout
  The system `protoc` version mismatch, require >= 3.1.0, got 27.3.x, fallback to the bundled `protoc`

  --- stderr
  thread 'main' panicked at /Users/davidviejo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protobuf-build-0.14.1/src/protobuf_impl.rs:35:14:
  No suitable `protoc` (>= 3.1.0) found in PATH
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@dviejokfs
Copy link

I think I see the issue, it's because of the --version command that is returning libprotoc 27.3

@dviejokfs
Copy link

Now it's working, for anyone else facing this problem I had to:

Install protobuf 3.20:

brew install [email protected]

Then copy protoc to the bin directory:

sudo cp /opt/homebrew/Cellar/protobuf@3/3.20.3/bin/protoc /usr/local/bin/protoc 

And verify the version of protoc

protoc --version

The major must be 3, otherwise it won't work on mac m1/m2/m3/m4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants