Setting Up the Basic Development Environment
Setting Up the Mac Environment
Main Steps
TIP
⚠️ Note: The project currently includes a rust-toolchain.toml
file by default, so it will use the Rust environment configured in that file. If you have installed Rust via Homebrew, you may encounter version conflicts. You will need to uninstall Rust and then set up the environment according to the instructions below.
To run the code, you need to set up the Rust development environment first. After initializing the Rust environment, the project mainly depends on cmake
, rocksdb
, and protoc
. You need to install these dependencies based on your operating system.
Install Rust Basic Environment
Reference Document: https://course.rs/first-try/installation.html
Rust Version The current Rust version required is
stable
.shellrustup install stable rustup default stable rustc --version
Install Cmake Installation command for macOS:
shellbrew install cmake
Install RocksDB Reference Document: https://github.com/rust-rocksdb/rust-rocksdb. Installation command for macOS:
shellbrew install rocksdb
Install Protoc Reference Document: https://www.jianshu.com/p/341293ee1286. Installation command for macOS:
shellbrew install protobuf
Pre-Commit Plugin
The main RobustMQ repository and the RobustMQ PB protocol repository Robust-Proto both use pre-commit
for code pre-commit by default, so you need to install a specified version of the pre-commit
tool. For more information about pre-commit
, refer to the official documentation.
TIP
For Robust-Proto, you also need to install the buf tool in advance:
brew install bufbuild/buf/buf
First, you need to create a virtual environment using Python
(version 3.8 or higher). The installation command is as follows:
python3 -m venv precommit_venv
After installation, activate the virtual environment with the following command:
source ./precommit_venv/bin/activate
Then, install the specified version of pre-commit
using the project's environment:
pip3 install -r ./.requirements-precommit.txt
After installation, initialize the pre-commit
hooks for the project content with the following command:
pre-commit install
TIP
⚠️ Note:
- For any subsequent
git commit
operations,pre-commit
will execute the corresponding checks. If you don't want to run the checks every time you commit, you can usegit commit -n
to skip the checks. - The
pre-commit
checks have been set to thestage
; for tests and strict checks, they will be executed at thepre-push
stage. To install thepre-push
hooks, you need to usepre-commit install --hook-type pre-push
.
The checks carried by pre-commit
use tools such as next-test
, hawkeye
, clippy
, typos
, and cargo-deny
. If any of these tools are missing, you can install them using the following commands:
cargo install hawkeye@5.8.1
cargo install typos-cli
cargo install cargo-deny@0.16.2 --locked
cargo install cargo-nextest@0.9.84