A command-line tool that analyzes Solana/Anchor projects to detect or infer required versions of Rust, Solana, and Anchor.
- Detects versions from multiple configuration files:
rust-toolchain
for Rust versionAnchor.toml
for Solana and Anchor versionsCargo.toml
for Solana and Anchor dependencies
- Prints commands to make local environment compatible (solana-install, avm, rustup)
- Recursively searches subdirectories if versions aren't found in the root
- Intelligently infers missing versions based on compatibility rules
- Skips irrelevant directories (node_modules, target, etc.)
- Handles various version specification formats
- Falls back to compatibility-based version inference when needed
Run the tool by providing a path to your Solana/Anchor project:
cargo run -- /path/to/your/project
Example output:
Detected/Inferred Versions:
Rust: nightly-2023-10-29 (from /path/to/project/rust-toolchain)
Solana: 1.18.10
Anchor: 0.29.0
To work with this project, configure your environment as follows:
rustup default nightly-2023-10-29
solana-install init 1.18.10
avm use 0.29.0
-
Top-level Check: First checks the root directory for version information in configuration files.
-
Recursive Search: If versions are missing, recursively searches subdirectories while skipping common irrelevant directories like
node_modules
andtarget
. -
Version Detection:
- Reads
rust-toolchain
for Rust version (supports both plain text and TOML formats) - Parses
Anchor.toml
for Solana and Anchor versions - Checks
Cargo.toml
for dependency versions
- Reads
-
Version Inference: If versions are still missing after searching, uses compatibility rules to infer appropriate versions based on known working combinations.
1.69.0
or
[toolchain]
channel = "1.69.0"
[toolchain]
anchor_version = "0.29.0"
solana_version = "1.18.10"
[dependencies]
solana-program = "1.17.0"
anchor-lang = { version = "0.29.0" }
- Split into multiple files (different ones for different kinds of parsing)
- Add clippy lints
- Reduce dependencies