solana-edition-fixer
v1.0.0
Published
Fix Rust edition 2024 compatibility issues for Solana/Anchor projects. Automatically downgrades problematic crate versions to work with Solana's toolchain.
Maintainers
Readme
Solana Edition Fixer
Fix Rust edition 2024 compatibility issues for Solana/Anchor projects.
Many Rust crates now require edition = "2024", but Solana's platform-tools use Cargo 1.75-1.84 which doesn't support it. This tool automatically downgrades problematic dependencies to compatible versions.
The Problem
When building Solana programs, you may see errors like:
error: failed to download `blake3 v1.8.3`
Caused by:
feature `edition2024` is required
The package requires the Cargo feature called `edition2024`, but that feature is
not stabilized in this version of Cargo (1.75.0).This happens because:
- Solana platform-tools (v1.42 - v1.52) bundle Cargo 1.75 - 1.84
- Rust edition 2024 requires Cargo 1.85+
- Many popular crates have updated to edition 2024
Quick Start
Option 1: npx (Recommended)
# Check for issues
npx solana-edition-fixer
# Apply fixes
npx solana-edition-fixer --fixOption 2: Global Install
npm install -g solana-edition-fixer
# Then use anywhere
solana-edition-fixer --fix
# or the short alias
sef --fixOption 3: Shell Script (No Node.js Required)
curl -sSL https://raw.githubusercontent.com/IsSlashy/solana-edition-fixer/main/scripts/fix-edition2024.sh | bashUsage
solana-edition-fixer [options] [project-path]
Options:
--fix, -f Apply fixes automatically
--dry-run, -d Show what would be changed (default)
--check, -c Check only, exit with error if issues found (for CI)
--verbose, -v Show detailed output
--json Output as JSON
--quiet, -q Minimal output
--help, -h Show help message
--version Show version numberExamples
# Check current directory
solana-edition-fixer
# Check specific project
solana-edition-fixer ./my-anchor-project
# Apply fixes automatically
solana-edition-fixer --fix
# Use in CI/CD (fails if issues found)
solana-edition-fixer --check
# Get JSON output for scripting
solana-edition-fixer --json | jq '.issues'What It Does
- Scans your
Cargo.lockfor dependencies requiring edition 2024 - Identifies problematic crate versions using our curated database
- Runs
cargo update -p <crate> --precise <version>to downgrade - Creates
.cargo/config.tomlwith MSRV-aware resolver settings
Fixed Crates
The tool fixes 40+ crates including:
| Crate | Incompatible | Compatible |
|-------|-------------|------------|
| blake3 | >= 1.6.0 | 1.5.0 |
| constant_time_eq | >= 0.4.0 | 0.3.1 |
| base64ct | >= 1.7.0 | 1.6.0 |
| subtle | >= 2.6.0 | 2.5.0 |
| zeroize | >= 1.8.0 | 1.7.0 |
| wit-bindgen | >= 0.25.0 | 0.24.0 |
| yoke | >= 0.8.0 | 0.7.4 |
See data/edition2024-database.json for the complete list.
Manual Fix
If you prefer to fix manually:
1. Add to Cargo.toml
[package]
# ... your package info
rust-version = "1.75" # Enables MSRV-aware resolver
[patch.crates-io]
# Pin problematic crates
blake3 = "=1.5.0"
constant_time_eq = "=0.3.1"2. Create .cargo/config.toml
[resolver]
incompatible-rust-versions = "fallback"
[net]
git-fetch-with-cli = true
[registries.crates-io]
protocol = "sparse"3. Run cargo update
cargo update -p blake3 --precise 1.5.0
cargo update -p constant_time_eq --precise 0.3.1CI/CD Integration
GitHub Actions
- name: Fix Solana Dependencies
run: npx solana-edition-fixer --fix
- name: Build Solana Program
run: cargo build-sbfCheck Mode
Use --check to fail CI if issues are found:
- name: Check Dependencies
run: npx solana-edition-fixer --checkProgrammatic API
const { analyze, applyFixes, database } = require('solana-edition-fixer');
// Analyze a project
const result = analyze('./my-project');
console.log(result.issues);
// Apply fixes
if (result.issues.length > 0) {
const fixResult = applyFixes('./my-project', result.issues);
console.log(`Fixed ${fixResult.updated.length} dependencies`);
}
// Access the database directly
console.log(database.crates['blake3'].maxCompatible); // "1.5.0"Contributing
Found a new problematic crate? Please contribute!
- Fork the repository
- Add the crate to
data/edition2024-database.json:
{
"new-crate": {
"maxCompatible": "X.Y.Z",
"firstIncompatible": "X.Y.W",
"reason": "X.Y.W+ requires edition 2024",
"usedBy": ["parent-crate"],
"priority": "medium"
}
}- Submit a PR
Why Not Just Upgrade Solana?
Solana's toolchain is intentionally conservative about Rust versions to ensure:
- Deterministic builds across all validators
- BPF/SBF bytecode compatibility
- Security audit consistency
Until Solana's platform-tools upgrade to Cargo 1.85+, this workaround is necessary.
Related Links
License
MIT - Created by IsSlashy / Volta Team
Found this helpful? Give us a star on GitHub!
