Coder Social home page Coder Social logo

cargo-tree's Introduction

cargo-tree

CircleCI Latest Version

cargo tree is a Cargo subcommand that visualizes a crate's dependency graph in a tree-like format.

Requirements: cmake and openssl.

  • macOS (via homebrew): brew install cmake openssl
  • Debian/Ubuntu: apt install cmake libssl-dev pkg-config

Install it with Cargo:

$ cargo install cargo-tree

In its default mode, cargo tree will print the "normal" dependencies of the local crate:

$ cargo tree
postgres v0.10.2 (file:///Volumes/git/rust/rust-postgres)
├── bufstream v0.1.1
├── byteorder v0.4.2
├── hex v0.1.0
├── log v0.3.4
│   └── libc v0.2.4
├── net2 v0.2.20
│   ├── cfg-if v0.1.0
│   ├── kernel32-sys v0.2.1
│   │   └── winapi v0.2.5
│   ├── libc v0.2.4 (*)
│   ├── winapi v0.2.5 (*)
│   └── ws2_32-sys v0.2.1
│       └── winapi v0.2.5 (*)
└── phf v0.7.9
    └── phf_shared v0.7.9

Crates will only have their dependencies displayed the first time they are shown - further copies will have a (*) appended to indicate that their output has been truncated.

Like other cargo subcommands, features can be enabled via the --features flag:

$ cargo tree --features serde_json
postgres v0.10.2 (file:///Volumes/git/rust/rust-postgres)
├── bufstream v0.1.1
├── byteorder v0.4.2
├── hex v0.1.0
├── log v0.3.4
│   └── libc v0.2.4
├── net2 v0.2.20
│   ├── cfg-if v0.1.0
│   ├── kernel32-sys v0.2.1
│   │   └── winapi v0.2.5
│   ├── libc v0.2.4 (*)
│   ├── winapi v0.2.5 (*)
│   └── ws2_32-sys v0.2.1
│       └── winapi v0.2.5 (*)
├── phf v0.7.9
│   └── phf_shared v0.7.9
└── serde_json v0.6.0
    ├── num v0.1.29
    │   ├── rand v0.3.12
    │   │   ├── advapi32-sys v0.1.2
    │   │   │   └── winapi v0.2.5 (*)
    │   │   ├── libc v0.2.4 (*)
    │   │   └── winapi v0.2.5 (*)
    │   └── rustc-serialize v0.3.16
    └── serde v0.6.7
        └── num v0.1.29 (*)

cargo tree can also operate in an "inverse" mode where the dependency tree is walked backwards. This is most often useful when trying to determine where a certain crate is coming from. The --package or -p flag selects the crate to use as the root of the tree and the --invert or -i flag inverts the dependency graph traversal:

$ cargo tree --features serde_json -p libc -i
libc v0.2.4
├── log v0.3.4
│   └── postgres v0.10.2 (file:///Volumes/git/rust/rust-postgres)
├── net2 v0.2.20
│   └── postgres v0.10.2 (file:///Volumes/git/rust/rust-postgres) (*)
└── rand v0.3.12
    └── num v0.1.29
        ├── serde v0.6.7
        │   └── serde_json v0.6.0
        │       └── postgres v0.10.2 (file:///Volumes/git/rust/rust-postgres) (*)
        └── serde_json v0.6.0 (*)

More options are available - see the output of cargo tree --help for details.

cargo-tree's People

Contributors

bossmc avatar brahmlower avatar est31 avatar fauxfaux avatar fbernier avatar gnmerritt avatar infinity0 avatar lexxvir avatar matthewkmayer avatar matthiaskrgr avatar nebkor avatar ralfjung avatar reynoldsbd avatar sfackler avatar viraptor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.