|
1 | 1 | # Cargo support
|
2 | 2 |
|
3 |
| -## Overview |
| 3 | +## Overview |
4 | 4 |
|
5 |
| -[detect_product_short] runs the Cargo detector if it finds either of the following files in your project: |
| 5 | +[detect_product_short] now includes two Cargo detectors: |
6 | 6 |
|
7 |
| -* Cargo.toml |
8 |
| -* Cargo.lock |
| 7 | +* **Cargo CLI Detector** (New) |
| 8 | +* **Cargo Lockfile Detector** |
9 | 9 |
|
10 |
| -The Cargo detector parses the Cargo.lock file for information on your project's dependencies. If the detector discovers a Cargo.toml file but not a Cargo.lock file, it will prompt the user to generate a Cargo.lock by running `cargo generate-lockfile` and then run [detect_product_short] again. |
11 |
| -The Cargo detector extracts the project's name and version from the Cargo.toml file. If it does not find a Cargo.toml file, it will defer to values derived by Git, from the project's directory, or defaults. |
| 10 | +## Cargo CLI Detector |
| 11 | + |
| 12 | +A new cli detector for Cargo projects, which extracts **direct and transitive dependencies** using the `cargo tree` command. This improves the accuracy of dependency detection over the previous flat-list detection. |
| 13 | + |
| 14 | +**Requirements:** |
| 15 | +* Cargo version **1.44.0+** is required (as `cargo tree` was introduced in this version). |
| 16 | +* A `Cargo.toml` file must be present in the project. |
| 17 | +* A valid `cargo` executable must be available on the system. |
| 18 | + |
| 19 | +**Behavior:** |
| 20 | +* Executes `cargo tree` to analyze dependencies. |
| 21 | +* Parses the output to construct a hierarchical **dependency graph**. |
| 22 | +* Falls back to the Cargo Lockfile Detector if `cargo tree` is unavailable. |
| 23 | + |
| 24 | +To specify a custom Cargo executable path, use the `detect.cargo.path` property. |
| 25 | + |
| 26 | +## Cargo Lockfile Detector |
| 27 | + |
| 28 | +If `cargo tree` is unavailable, [detect_product_short] will default to the Cargo Lockfile Detector, which extracts dependencies by parsing the `Cargo.lock` file. |
| 29 | + |
| 30 | +* If both `Cargo.toml` and `Cargo.lock` are present, the detector uses `Cargo.lock` for dependency information. |
| 31 | +* If `Cargo.lock` is missing, the detector prompts the user to generate it using `cargo generate-lockfile`. |
| 32 | +* Extracts the project’s name and version from `Cargo.toml`. If missing, it derives values from Git or the project directory. |
0 commit comments