Installing diagrams-builder with stack

28 views
Skip to first unread message

Sam Tay

unread,
Feb 5, 2020, 9:55:11 AM2/5/20
to diagrams...@googlegroups.com
Hi,

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!

Sam

Brent Yorgey

unread,
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.

-Brent

--
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 diagrams-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diagrams-discuss/CAJtde5P8v6XA6Om1WqQ13dyJtB5A3axB8Ac6ih1R8QQ%3D7n6RNA%40mail.gmail.com.

Sam Tay

unread,
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 }%

Cheers,
Sam

Brent Yorgey

unread,
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: []

extra-deps:
- diagrams-pgf-1.4.1
- diagrams-rasterific-1.4.1.1
- texrunner-0.0.1.2
- diagrams-builder-0.8.0.4
- haskell-src-exts-simple-1.20.0.0

flags:
  diagrams-builder:
    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.

-Brent

greg travis

unread,
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-1.4.1.1
- cairo-0.13.8.0
- pango-0.13.8.0
- glib-0.13.8.0
- gtk2hs-buildtools-0.13.8.0
- 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

unread,
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: https://github.com/haskell-gi/haskell-gi

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

-Brent

--
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 diagrams-discu...@googlegroups.com.

greg travis

unread,
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-0.1.0.0:
    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: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package gobject-introspection
    (use -v for more information)

err.txt
Reply all
Reply to author
Forward
0 new messages