There is a mistake in the documentation where it explains how to generate the PNG file for Graphiz

G-d willing

Hello,
I would like to mention that there is a mistake in the command that explains how to generate the PNG from when using Graphiz.

In here, you can see that the command is:
dot -Tpng <project_name>.dot > <project_name>.png

The “-o” is missing in the command and it should be:
dot -Tpng <project_name>.dot > -o <project_name>.png

Thanks,

$ daml new t
Created a new project in "t" based on the template "skeleton".
$ cd t
$ daml build

2022-03-24 13:09:55.97 [INFO]  [build] 
Compiling t to a DAR.

2022-03-24 13:09:56.74 [INFO]  [build] 
Created .daml/dist/t-0.0.1.dar
$ daml damlc visual .daml/dist/t-0.0.1.dar --dot my-dot-file.dot
$ dot -Tpng my-dot-file.dot > my-png-file.png
$ open my-png-file.png 
$ 

works as expected for me. But:

$ rm my-png-file.png          
$ dot -Tpng my-dot-file.dot > -o my-png-file.png
Error: dot: can't open my-png-file.png: No such file or directory
$ ls -l
total 24
-rw-r--r-- 1 garyverhaegen wheel 12798 Mar 24 14:14 -o
drwxr-xr-x 3 garyverhaegen wheel    96 Mar 24 14:09 daml
-rw-r--r-- 1 garyverhaegen wheel   251 Mar 24 14:09 daml.yaml
-rw-r--r-- 1 garyverhaegen wheel   417 Mar 24 14:10 my-dot-file.dot
$

The problem with the dot -Tpng my-dot-file.dot > -o my-png-file.png line is that, per Bash parsing rules, dot sees the arguments -Tpng my-dot-file.dot my-png-file.png while having its output redirected to the file called -o.

You could use the -o option, but then you shouldn’t have a redirect (>):

$ dot -Tpng my-dot-file.dot -o my-png-file.png 
$ ls -l
total 40
-rw-r--r-- 1 garyverhaegen wheel 12798 Mar 24 14:14 -o
drwxr-xr-x 3 garyverhaegen wheel    96 Mar 24 14:09 daml
-rw-r--r-- 1 garyverhaegen wheel   251 Mar 24 14:09 daml.yaml
-rw-r--r-- 1 garyverhaegen wheel   417 Mar 24 14:10 my-dot-file.dot
-rw-r--r-- 1 garyverhaegen wheel 12798 Mar 24 14:16 my-png-file.png
$

In summary, using the notation from the docs:

  • dot -Tpng <project_name>.dot > <project_name>.png works as expected.
  • dot -Tpng <project_name>.dot -o <project_name>.png also works.
  • dot -Tpng <project_name>.dot > -o <project_name>.png does not work.

It’s unfortunate that the docs uses <project_name> as a placeholder for names here as:

  1. There’s really no reason to use the name of the project; all you need is to make up two file names, one for the dotfile and one for the png file.
  2. The use of <> as delimiters for the placeholder name is really bad, given the significance of these symbols in Bash and most other shells.
1 Like

Well, it’s my bad as I didn’t notice that there is a > sign in the command itself. So basically, I was running the command incorrectly.
Basically, since the usage of “<” and “>” signs were used in the command as a sign for placeholders, it blurred it when I actually needed to type it.

Thanks.

I’ve opened a pull request to improve that page moving forward.

2 Likes