cargo-shear
brew install cargo-shear
v1.13.1
MIT
Detect and remove unused dependencies from `Cargo.toml` in Rust projects
61
30-day installs · #4293
158
90-day · #4612
710
365-day · #4407
534
★ GitHub stars · updated 2mo ago
Build dependencies
Links
- https://github.com/Boshen/cargo-shear
- GitHub: Boshen/cargo-shear
- Brew formula source: Formula/c/cargo-shear.rb
Raw metadata
{
"aliases": [],
"alternatives": [],
"build_dependencies": [
"rust"
],
"categories": [],
"caveats": null,
"conflicts_with": [],
"dependencies": [],
"deprecated": 0,
"deprecation_reason": null,
"desc": "Detect and remove unused dependencies from `Cargo.toml` in Rust projects",
"disable_reason": null,
"disabled": 0,
"enrichment_fetched_at": "2026-06-20T23:36:09+00:00",
"first_seen": "2026-06-20T23:34:18+00:00",
"full_name": "cargo-shear",
"github_default_branch": "main",
"github_last_commit_at": "2026-06-14T18:12:40Z",
"github_readme_excerpt": "# Cargo Shear \u2702\ufe0f \ud83d\udc11\n\nDetect and fix issues in Rust projects:\n\n- **Unused dependencies** in `Cargo.toml`\n- **Misplaced dependencies** (dev/build dependencies in wrong sections)\n- **Unlinked source files** (Rust files not reachable from any module tree)\n\n\u003e [!NOTE]\n\u003e This tool is considered feature-complete. We continue to welcome contributions that focus on bug fixes, dependency upgrades, and UI/UX improvements.\n\n## Installation\n\n```bash\n# Install from pre-built binaries.\ncargo binstall cargo-shear\n\n# Build from source.\ncargo install cargo-shear\n\n# Install from brew.\nbrew install cargo-shear\n```\n\n## Usage\n\nCheck for issues without making changes:\n\n```bash\ncargo shear\n```\n\nAutomatically fix unused dependencies:\n\n```bash\ncargo shear --fix\n```\n\nTreat warnings as errors (exit with failure code):\n\n```bash\ncargo shear --deny-warnings\n```\n\nThis is useful for CI/CD pipelines to enforce strict checking of warnings such as empty files, unlinked files, and unused optional dependencies.\n\nGenerate machine-readable JSON output:\n\n```bash\ncargo shear --format=json\n```\n\nThis is particularly useful for CI/CD pipelines and custom tooling that need to programmatically process the results.\n\nDetect mismatches between `[lib]` target settings and source content:\n\n```bash\ncargo shear --check-test-targets\n```\n\nWhen set, cargo-shear warns when `test = false` is paired with source that contains tests (or `doctest = false` with source that contains doc tests), and \u2014 within a workspace \u2014 when `test` / `doctest` are left at their default of `true` for lib targets that contain none. Disabled by default; pair with `--fix` to automatically reconcile the flags.\n\n## Limitations\n\n\u003e [!IMPORTANT]\n\u003e `cargo shear` cannot detect \"hidden\" imports from macro expansions without the `--expand` flag (nightly only).\n\u003e This is because `cargo shear` uses rust-analyzer\u0027s parser to parse files and does not expand macros by default.\n\nTo expand macros:\n\n```bash\ncargo shear --expand --fix\n```\n\nThe `--expand` flag uses `car",
"github_repo": "Boshen/cargo-shear",
"github_stars": 534,
"github_topics": [],
"homepage": "https://github.com/Boshen/cargo-shear",
"homepage_og_description": null,
"homepage_og_image": null,
"homepage_title": null,
"installs_30d": 61,
"installs_365d": 710,
"installs_90d": 158,
"keg_only": 0,
"keg_only_reason": null,
"last_seen": "2026-06-20T23:34:18+00:00",
"license": "MIT",
"llm_generated_at": null,
"llm_model": null,
"name": "cargo-shear",
"oldnames": [],
"one_liner": null,
"optional_dependencies": [],
"rank_30d": 4293,
"rank_365d": 4407,
"rank_90d": 4612,
"raw_hash": "dc7da1b64ba0af95",
"recommended_dependencies": [],
"revision": 0,
"ruby_source_path": "Formula/c/cargo-shear.rb",
"tap": "homebrew/core",
"test_dependencies": [
"rustup"
],
"uses_from_macos": [],
"version_head": "HEAD",
"version_stable": "1.13.1",
"versioned_formulae": [],
"why_use_this": null
}