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
.
rustup install stable
rustup default stable
rustc --version
- Install Cmake
- Installation command for macOS:
brew install cmake
- Install RocksDB
- Reference Document: https://github.com/rust-rocksdb/rust-rocksdb
- Installation command for macOS:
brew install rocksdb
- Install Protoc
- Reference Document: https://www.jianshu.com/p/341293ee1286
- Installation command for macOS:
brew install protobuf
Configuring the pre-commit Plugin
RobustMQ uses pre-commit
by default for code pre-commit checks, so you need to install the specified version of the pre-commit
tool.
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