Installing diagrams-builder with stack

Skip to first unread message

Sam Tay

Feb 5, 2020, 9:55:11 AM2/5/20

I use stack instead of cabal. Is this not supported by diagrams-builder?

I've successfully installed the executable diagrams-builder-ps for use within Latex, but whenever I try to run pdflatex --enable-write18 hw.tex, I get the error that Diagrams.Prelude (and others) not found. So the interpreter in diagrams-builder-ps is not able to find the local package database used in my global stack instance, I suppose?

Any help much appreciated! Thanks!


Brent Yorgey

Feb 6, 2020, 6:47:23 AM2/6/20
to Sam Tay, diagrams-discuss
I definitely use diagrams-builder with stack, but it is a bit tricky to get everything configured correctly.  I will get back to you soon with more details.


You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Sam Tay

Feb 6, 2020, 12:19:56 PM2/6/20
to Brent Yorgey, diagrams-discuss
Thank you! I got this working with Ryan's comment but forgot to reply-all. For anyone wondering in the future, this worked as expected after modifying the executable call from the "diagrams-latex.sty" file:

\immediate\write18{\dtt@cmdprefix stack exec diagrams-builder-\dtt@backend\space -- -o \dtt@figname.\dtt@extension\space \dtt@width\space \dtt@height\space \d...@figname.hs\space }%


Brent Yorgey

Feb 11, 2020, 6:59:24 AM2/11/20
to Sam Tay, diagrams-discuss
Glad you got it working!  Just for future reference, here's how I usually set things up:

- I make a stack.yaml file with contents something like the following:

resolver: lts-13.27
packages: []

- diagrams-pgf-1.4.1
- diagrams-rasterific-
- texrunner-
- diagrams-builder-
- haskell-src-exts-simple-

    pgf: true
    rasterific: true

The important part here is the 'flags' section which makes sure that the diagrams-builder-pgf and diagrams-builder-rasterific executables will be installed (just the -pgf one would do as well, depending on your needs).

- Then I call pdflatex with a command like

stack exec --package diagrams-lib --package diagrams-pgf --package diagrams-contrib --package diagrams-builder --package palette -- pdflatex --enable-write18 lectures.tex

(with whatever packages I need).  I'm not sure if all of this is 100% necessary, but this is the way I've been able to get things to consistently work without creating an actual Haskell package with a .cabal file etc.  In particular without the --package arguments it seems that stack sometimes gets confused about what needs to be in scope in the exec environment while running pdflatex.


greg travis

Mar 3, 2020, 2:59:03 PM3/3/20
to diagrams-discuss
I'm trying to get diagrams-cairo building under stack. My extra-deps currently looks like this:

- diagrams-cairo-
- cairo-
- pango-
- glib-
- gtk2hs-buildtools-
- gi-pangocairo-1.0.23

At this point it says haskell-gi depends on gobject-introspection; but that package does not exist on Hackage. Is it just impossible to use diagrams-cairo with stack?

Brent Yorgey

Mar 3, 2020, 4:01:24 PM3/3/20
to greg travis, diagrams-discuss
It might be referring to a C library or some other sort of external dependency rather than a Haskell package, perhaps?  See the instructions here:

What OS / distribution are you using?  And can you share the exact error message you are getting?


You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to

greg travis

Mar 4, 2020, 3:47:25 PM3/4/20
to Brent Yorgey, diagrams-discuss
Error message attached and pasted below. Installing the dependencies of haskell-gi didn't change anything; but I'm not really sure how to install haskell-gi itself.


Using main module: 1. Package `autobeat' component autobeat:exe:autobeat with main-is file: /home/gtravis/personal/autobeat/src/Main.hs

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for autobeat-
    gobject-introspection needed, but the stack configuration has no specified version (no package
                          with that name found, perhaps there is a typo in a package's build-depends
                          or an omission from the stack.yaml packages list?)
needed since autobeat is a build target.

Some different approaches to resolving this:

Error: Plan construction failed.

Warning: Build failed, but trying to launch GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
Configuring GHCi with the following packages: autobeat
GHCi, version 8.6.5:  :? for help
<command line>: cannot satisfy -package gobject-introspection
    (use -v for more information)

Reply all
Reply to author
0 new messages