|
| 1 | +# Migrating from cargo-hakari |
| 2 | + |
| 3 | +If you're using `cargo-hakari` or a workspace hack crate, migration takes about 5 minutes. |
| 4 | + |
| 5 | +## Why migrate? |
| 6 | + |
| 7 | +- **No more meta-crate** cluttering your workspace |
| 8 | +- **Single config file** instead of hakari.toml + workspace-hack crate |
| 9 | +- **Resolution-based** - uses Cargo's actual resolver output |
| 10 | +- **Multi-target aware** - computes intersections across all your target triples |
| 11 | + |
| 12 | +## Steps |
| 13 | + |
| 14 | +### 1. Create a branch |
| 15 | + |
| 16 | +```bash |
| 17 | +git checkout -b migrate-to-rail |
| 18 | +``` |
| 19 | + |
| 20 | +### 2. Remove cargo-hakari setup |
| 21 | + |
| 22 | +```bash |
| 23 | +# Remove the workspace-hack crate |
| 24 | +rm -rf crates/workspace-hack # or wherever yours lives |
| 25 | + |
| 26 | +# Remove from workspace members in root Cargo.toml |
| 27 | +# Remove workspace-hack dependency from all member Cargo.tomls |
| 28 | +# Delete .config/hakari.toml if present |
| 29 | +``` |
| 30 | + |
| 31 | +### 3. Initialize cargo-rail |
| 32 | + |
| 33 | +```bash |
| 34 | +cargo install cargo-rail |
| 35 | +cargo rail init |
| 36 | +``` |
| 37 | + |
| 38 | +### 4. Enable transitive pinning |
| 39 | + |
| 40 | +Edit `.config/rail.toml`: |
| 41 | + |
| 42 | +```toml |
| 43 | +[unify] |
| 44 | +pin_transitives = true # This replaces cargo-hakari |
| 45 | +msrv = true # Optional: compute MSRV from deps |
| 46 | +prune_dead_features = true |
| 47 | +``` |
| 48 | + |
| 49 | +### 5. Run unify |
| 50 | + |
| 51 | +```bash |
| 52 | +# Preview first |
| 53 | +cargo rail unify --check |
| 54 | + |
| 55 | +# Apply changes |
| 56 | +cargo rail unify |
| 57 | +``` |
| 58 | + |
| 59 | +### 6. Verify |
| 60 | + |
| 61 | +```bash |
| 62 | +cargo check --workspace |
| 63 | +cargo test --workspace |
| 64 | +``` |
| 65 | + |
| 66 | +### 7. Commit |
| 67 | + |
| 68 | +```bash |
| 69 | +git add -A |
| 70 | +git commit -m "chore: migrate from cargo-hakari to cargo-rail" |
| 71 | +``` |
| 72 | + |
| 73 | +## What `pin_transitives` does |
| 74 | + |
| 75 | +Instead of a workspace-hack crate that forces dependency unification, cargo-rail: |
| 76 | + |
| 77 | +1. Analyzes the resolved dependency graph per target triple |
| 78 | +2. Identifies transitive dependencies used by multiple workspace members |
| 79 | +3. Pins them in `[workspace.dependencies]` at the root |
| 80 | +4. Updates member `Cargo.toml` files to use `workspace = true` |
| 81 | + |
| 82 | +The result is the same build graph optimization without the meta-crate. |
| 83 | + |
| 84 | +## Differences from cargo-hakari |
| 85 | + |
| 86 | +| cargo-hakari | cargo-rail | |
| 87 | +|--------------|------------| |
| 88 | +| Workspace-hack crate | No extra crate | |
| 89 | +| hakari.toml config | rail.toml config | |
| 90 | +| `cargo hakari generate` | `cargo rail unify` | |
| 91 | +| Single target | Multi-target (parallel) | |
| 92 | +| Syntax-based | Resolution-based | |
| 93 | + |
| 94 | +## Rollback |
| 95 | + |
| 96 | +If something goes wrong: |
| 97 | + |
| 98 | +```bash |
| 99 | +cargo rail unify undo |
| 100 | +``` |
| 101 | + |
| 102 | +This restores from the automatic backup created during unify. |
0 commit comments