Skip to content

Commit 53770fe

Browse files
fix: --graph=foo.dot should not require graphviz installed (#10942)
### Description I'm attempting to use `turbo ... --graph` in GHA to do some static analysis of a very large repository. It's easy enough to extract relevant patterns from a `.dot` file, but I wouldn't have expected to need graphviz installed if I'm not actually using it. I guess it turns out we _are_ using it, to do `dot - -T dot > out.dot`, but this seems very odd when the `std::io::stdout()` case just outputs directly. Seems like a bug. ### Testing Instructions Edit your `PATH` to remove where graphviz is installed, then ```bash turbo run build --graph foo.dot ``` Prior to this PR, you should get the error ` WARNING `turbo` uses Graphviz to generate an image of your graph, but Graphviz isn't installed on this machine.` and an empty `foo.dot`. After this PR, you should end up with a populated dotfile and no warning. --------- Co-authored-by: Anthony Shew <[email protected]>
1 parent 7720979 commit 53770fe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/turborepo-lib/src/run/graph_visualizer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ pub(crate) fn write_graph(
3939
render_mermaid_graph(&filename, engine, single_package)?;
4040
} else if extension == "html" {
4141
render_html(&filename, engine, single_package)?;
42+
} else if extension == "dot" {
43+
let mut opts = OpenOptions::new();
44+
opts.truncate(true).create(true).write(true);
45+
let file = filename
46+
.open_with_options(opts)
47+
.map_err(Error::GraphOutput)?;
48+
render_dot_graph(file, engine, single_package)?;
4249
} else if let Ok(dot_path) = which("dot") {
4350
let mut cmd = Command::new(dot_path);
4451
cmd.stdin(Stdio::piped())

0 commit comments

Comments
 (0)