kbknapp / cargo-graph Goto Github PK
View Code? Open in Web Editor NEWA cargo subcommand for creating GraphViz DOT files and dependency graphs
License: BSD 3-Clause "New" or "Revised" License
A cargo subcommand for creating GraphViz DOT files and dependency graphs
License: BSD 3-Clause "New" or "Revised" License
I've got a crate with a mess like this:
[dependencies]
memchr = "0.1"
quickcheck = { version = "0.2", optional = true }
itertools = { version = "0.4", optional = true }
odds = { version = "0.2", optional = true }
jetscii = {version = "0.3", features= ["unstable"], optional = true }
[dev-dependencies]
regex = "0.1"
itertools = "0.4"
odds = "0.2"
custom_derive = "0.1"
newtype_derive = "0.1"
rand = "0.3.10"
<stdin>:1:2: 1:3 error: unknown start of token: \\
<stdin>:1 C\:> setx path \"%path%;C:\path\to\cargo-graph\binary\"
^
thread '<unnamed>' panicked at 'Box<Any>', ../src/libsyntax/parse/lexer/mod.rs:1227
Could not document `cargo-graph`.
When running cargo graph
on an arbitrary project I receive the following error message:
% cargo graph
error: No root table found for toml file
I have no idea what this error means or how I can get more information about the problem. Any ideas?
cargo graph --dev-deps=false | dot -Tpng > Cargo.png
Also tried:
cargo graph --dev-color red | dot -Tpng > Cargo.png
Trying to update the dependency graph for https://github.com/PistonDevelopers/opengl_graphics
$ cargo graph --optional-deps false --dev-deps false | dot -Tpng > Cargo.png
This gets a graph where vecmath has wrong dependencies:
The only dependency of "vecmath" is "piston-float", but the graph shows these:
Don't know if you're still working on this, but I hope you are! It looks like Cargo 1.41 changed up the format of the Cargo.lock file, so now this only outputs error: No root table found for toml file
. If it's an easy fix I might be able to make a PR for it.
Thanks!
When using workspaces, Cargo.toml
's [root]
is basically just backwards compatibility and no longer points to master crate. This makes graph incomplete, cause it doesn't contain all crates from the workspace.
Full description of an issue can be found here: rust-lang/cargo#3203
Follow up on #15. Graph with deps look nice. Without dev-deps, it panics:
Node N14 doesn't exist, but it tries to add the edge N3 -> N14. N3 is memchr so the only thing it should link to is libc
.
$ RUST_BACKTRACE=1 ~/bin/cargo-graph graph
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:367
stack backtrace:
1: 0x5599470a91a0 - sys::backtrace::tracing::imp::write::h2121cc3fd481a5bfxXt
2: 0x5599470ab565 - panicking::log_panic::_<closure>::closure.41181
3: 0x5599470aafe0 - panicking::log_panic::h274f0982d2d31f5d62x
4: 0x55994709ed93 - sys_common::unwind::begin_unwind_inner::ha197e3d3bf39738b4Ps
5: 0x55994709f128 - sys_common::unwind::begin_unwind_fmt::h377d567d53530218aPs
6: 0x5599470a8801 - rust_begin_unwind
7: 0x5599470d7d6f - panicking::panic_fmt::hd08c5b6fdb7b10daxuL
8: 0x5599470d8048 - panicking::panic::h588d88296fb1b1954sL
9: 0x559946f4f942 - option::_<impl>::unwrap::unwrap::h16263530560132818147
at ../src/libcore/macros.rs:20
10: 0x559946f4ee67 - graph::_<impl>::label::h10115180723912119468
at src/graph.rs:17
11: 0x559946f490ff - graph::_<impl>::render_to::h7564755762930757336
at src/graph.rs:142
12: 0x559946f43159 - execute::h2d7033028e348fb8ogc
at src/main.rs:390
13: 0x559946f3d2ed - main::h75e0a80141ee56f0Ifc
at src/main.rs:378
14: 0x5599470aad84 - sys_common::unwind::try::try_fn::h1190371136003024825
15: 0x5599470a8648 - __rust_try
16: 0x5599470aaa26 - rt::lang_start::h63ca0c2ab43f095fe0x
17: 0x559946f43399 - main
18: 0x7f94da5bdb44 - __libc_start_main
19: 0x559946f30c38 - <unknown>
20: 0x0 - <unknown>
digraph dependencies {
N0[label="twoway"];
N1[label="itertools"];
N2[label="jetscii"];
N3[label="memchr"];
N4[label="odds"];
N5[label="quickcheck"];
N6[label="rand"];
N7[label="advapi32-sys"];
N8[label="winapi"];
N9[label="winapi-build"];
N10[label="libc"];
N11[label="log"];
N12[label="unreachable"];
N13[label="void"];
N0 -> N1[label=""];
N0 -> N2[label=""];
N0 -> N3[label=""];
N0 -> N4[label=""];
N0 -> N5[label=""];
N0 -> N6[label=""];
N0 -> N7[label=""];
N0 -> N8[label=""];
N0 -> N9[label=""];
N3 -> N14
Hi, would it be possible to add versions to the dependency edges?
Cargo graph currently panics often (not always) if the crate has some dev-dependencies.
To reproduce the bug, just create an empty crate with a single dev-dependency and try to run cargo graph a few times on it.
When starting cargo graph in windows' cmd shell, the output file is ASCII text. When you start it in windows' powershell, the output file is Little-endian UTF-16 Unicode text, with CRLF, CR line terminators and a byte order mark.
dot
fails to produce pngs from such a file:
PS C:\Users\Benni\repositories\parity> dot -Tpng > rainbow-graph.png cargo-count-ps.dot
Error: cargo-count-ps.dot: syntax error in line 1 near ' ■d'
To explore the structure of larger projects, e.g. in workspaces, it is helpful to be able to visually distinguish ‘external’ dependencies (e.g. crates.io crates) and in-house dependencies. There seems to be no feature to do this in v0.3.0.
hi! i wanted to ask if module dependencies within a crate are out of scope or could be implemented.
surely a bigger thing as we’d have to parse rust…
the utility would be detecting dependency cycles and therefore get help with better module structure.
This will help track down version conflict when cargo
is pulling in different versions of the same dependency again.
Hi!
I wanted to generate a dependency graph for mn mnemonic but cargo-graph gives me the error
File { fd: 3, path: "/home/swym/tmp/mnemonic/Cargo.toml", read: true, write: false }:11:1-11:8 duplicate key:
version
I failed to find a duplicate version key manually and also tomlcheck confirms that Cargo.lock seems fine.
gh won't let me attach Cargo.lock but you should be able to reproduce by git cloning mnemonic...
Compiling cargo-graph v0.3.0
Running `rustc /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/main.rs --crate-name cargo_graph --crate-type bin -C opt-level=3 --cfg feature=\"default\" --cfg feature=\"ansi_term\" --cfg feature=\"color\" -C metadata=78981140edc34098 --out-dir /tmp/cargo-install.RRnxogUmQG1e/release/deps --emit=dep-info,link -L dependency=/tmp/cargo-install.RRnxogUmQG1e/release/deps --extern clap=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libclap-5edb29158d4cdcf9.rlib --extern toml=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libtoml-43ec4e65006ca283.rlib --extern ansi_term=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libansi_term-2bdf8e6e86434248.rlib`
error: unnecessary qualification
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/config.rs:28:1
|
28 | arg_enum! {
| _^ starting here...
29 | | #[derive(Debug, Copy, Clone)]
30 | | pub enum DotLineShape {
31 | | Solid,
32 | | Dotted,
33 | | Dashed
34 | | }
35 | | }
| |_^ ...ending here
|
note: lint level defined here
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/main.rs:216:9
|
216| unused_qualifications)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate
error: unnecessary qualification
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/config.rs:47:1
|
47 | arg_enum!{
| ^
|
= note: this error originates in a macro outside of the current crate
error: unnecessary qualification
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/config.rs:76:1
|
76 | arg_enum!{
| _^ starting here...
77 | | #[derive(Debug, Copy, Clone)]
78 | | pub enum DotShape {
79 | | Box,
80 | | Round,
81 | | Diamond,
82 | | Triangle
83 | | }
84 | | }
| |_^ ...ending here
|
= note: this error originates in a macro outside of the current crate
error: aborting due to 3 previous errors
error: failed to compile `cargo-graph v0.3.0`, intermediate artifacts can be found at `/tmp/cargo-install.RRnxogUmQG1e`
Caused by:
Could not compile `cargo-graph`.
Caused by:
process didn't exit successfully: `rustc /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/main.rs --crate-name cargo_graph --crate-type bin -C opt-level=3 --cfg feature="default" --cfg feature="ansi_term" --cfg feature="color" -C metadata=78981140edc34098 --out-dir /tmp/cargo-install.RRnxogUmQG1e/release/deps --emit=dep-info,link -L dependency=/tmp/cargo-install.RRnxogUmQG1e/release/deps --extern clap=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libclap-5edb29158d4cdcf9.rlib --extern toml=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libtoml-43ec4e65006ca283.rlib --extern ansi_term=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libansi_term-2bdf8e6e86434248.rlib` (exit code: 101)
Default host: x86_64-unknown-linux-gnu
stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
arm-linux-androideabi
x86_64-unknown-linux-gnu
x86_64-unknown-linux-musl
cenos _7_64bit
I tried this on Servo, but there are enough crates that resulting graph is an unreadable mess. It’d be nice to be able to build a graph on only path
dependencies (those that don’t have a source
entry in Cargo.lock
), or have some other kind of filtering to graph fewer crates at a time.
Compiling cargo-graph v0.3.0
Running `rustc /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/main.rs --crate-name cargo_graph --crate-type bin -C opt-level=3 --cfg feature=\"default\" --cfg feature=\"ansi_term\" --cfg feature=\"color\" -C metadata=78981140edc34098 --out-dir /tmp/cargo-install.RRnxogUmQG1e/release/deps --emit=dep-info,link -L dependency=/tmp/cargo-install.RRnxogUmQG1e/release/deps --extern clap=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libclap-5edb29158d4cdcf9.rlib --extern toml=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libtoml-43ec4e65006ca283.rlib --extern ansi_term=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libansi_term-2bdf8e6e86434248.rlib`
error: unnecessary qualification
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/config.rs:28:1
|
28 | arg_enum! {
| _^ starting here...
29 | | #[derive(Debug, Copy, Clone)]
30 | | pub enum DotLineShape {
31 | | Solid,
32 | | Dotted,
33 | | Dashed
34 | | }
35 | | }
| |_^ ...ending here
|
note: lint level defined here
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/main.rs:216:9
|
216| unused_qualifications)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate
error: unnecessary qualification
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/config.rs:47:1
|
47 | arg_enum!{
| ^
|
= note: this error originates in a macro outside of the current crate
error: unnecessary qualification
--> /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/config.rs:76:1
|
76 | arg_enum!{
| _^ starting here...
77 | | #[derive(Debug, Copy, Clone)]
78 | | pub enum DotShape {
79 | | Box,
80 | | Round,
81 | | Diamond,
82 | | Triangle
83 | | }
84 | | }
| |_^ ...ending here
|
= note: this error originates in a macro outside of the current crate
error: aborting due to 3 previous errors
error: failed to compile `cargo-graph v0.3.0`, intermediate artifacts can be found at `/tmp/cargo-install.RRnxogUmQG1e`
Caused by:
Could not compile `cargo-graph`.
Caused by:
process didn't exit successfully: `rustc /home/zoumi/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-graph-0.3.0/src/main.rs --crate-name cargo_graph --crate-type bin -C opt-level=3 --cfg feature="default" --cfg feature="ansi_term" --cfg feature="color" -C metadata=78981140edc34098 --out-dir /tmp/cargo-install.RRnxogUmQG1e/release/deps --emit=dep-info,link -L dependency=/tmp/cargo-install.RRnxogUmQG1e/release/deps --extern clap=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libclap-5edb29158d4cdcf9.rlib --extern toml=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libtoml-43ec4e65006ca283.rlib --extern ansi_term=/tmp/cargo-install.RRnxogUmQG1e/release/deps/libansi_term-2bdf8e6e86434248.rlib` (exit code: 101)
*-------------------------------------------------------------------------------------
Default host: x86_64-unknown-linux-gnu
installed toolchains
*--------------------
stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
installed targets for active toolchain
*--------------------------------------
arm-linux-androideabi
x86_64-unknown-linux-gnu
x86_64-unknown-linux-musl
active toolchain
*----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.15.0-nightly (ebeee0e27 2016-12-04)
*---------------------------------------------------------------------------------------
cenos _7_64bit
Sorry for bugging you with tricky cases. Fix if you want to.
For crate petgraph, following command:
cargo graph --optional-color orange --optional-line-color orange --dev-deps true --dev-shape diamond --dev-color red --dev-line-style dashed --dev-line-color red | dot -Tpng > output.png
can produce different colorings of the graph, just rerun to get a chance at getting a different one.
There are more than two variants, but the main variations is the coloring of the regex cluster. Regex' deps are not optional, but seen from petgraph, they are all optional. So coloring them all orange seems to be the right thing?
https://lut.im/ymtK7rowOA/ptiIYH7gGXE8gXw3.svg
My crate doesn't have a direct non-optional dependency to dlib
, objc
, core-graphics
, cocoa
and core-foundation
, but theirs dependencies are marked as non-optional.
https://github.com/Yamakaky/dcpu
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.