Following the example package.yaml and diagrams library tutorial leads to any diagrams module not being found by stack. As far as I know, and have tested, this is only occuring with the Diagrams library
~/test | stack new diagTest | 12:24 PM
Downloading template "new-template" to create project "diagTest" in diagTest/ ...
The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/doyougnu/.stack/config.yaml, like this:
templates:
params:
author-email: value
author-name: value
category: value
copyright: value
github-username: value
Or you can pass each one as parameters like this:
stack new diagTest new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- diagTest/
Selecting the best among 13 snapshots...
* Matches lts-11.4
Selected resolver: lts-11.4
Initialising configuration using resolver: lts-11.4
Total number of user packages considered: 1
Writing configuration to file: diagTest/stack.yaml
All done.
diagrams to package.yaml and downgrade lts-11.4 to lts-10.10 per diagrams on stackage.~/test | cat diagTest/package.yaml | 12:24 PM
name: diagTest
version: 0.1.0.0
github: "githubuser/diagTest"
license: BSD3
author: "Author name here"
maintainer: "[email protected]"
copyright: "2018 Author name here"
extra-source-files:
- README.md
- ChangeLog.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on Github at <https://github.com/githubuser/diagTest#readme>
dependencies:
- base >= 4.7 && < 5
library:
source-dirs: src
executables:
diagTest-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- diagTest
tests:
diagTest-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- diagTest
~/test | cat diagTest/stack.yaml | 12:26 PM
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
# resolver: ghcjs-0.1.0_ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-11.4
# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
# - location:
# git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
# subdirs:
# - auto-update
# - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver
# using the same syntax as the packages field.
# (e.g., acme-missiles-0.3)
# extra-deps: []
# Override default flag values for local packages and extra-deps
# flags: {}
# Extra package databases containing global packages
# extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=1.7"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
md5-be0b62ba8421d75dcdc7c4afab74f718
~/test | cat diagTest/package.yaml | 12:28 PM
name: diagTest
version: 0.1.0.0
github: "githubuser/diagTest"
license: BSD3
author: "Author name here"
maintainer: "[email protected]"
copyright: "2018 Author name here"
extra-source-files:
- README.md
- ChangeLog.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on Github at <https://github.com/githubuser/diagTest#readme>
dependencies:
- base >= 4.7 && < 5
- diagrams # added
library:
source-dirs: src
executables:
diagTest-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- diagTest
tests:
diagTest-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- diagTest
md5-a142693a300760576a984eda41338bc6
~/test | cat diagTest/stack.yaml | 12:26 PM
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
# resolver: ghcjs-0.1.0_ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
# resolver: lts-11.4
resolver: lts-10.10 #changed to 10.10
# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
# - location:
# git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
# subdirs:
# - auto-update
# - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver
# using the same syntax as the packages field.
# (e.g., acme-missiles-0.3)
# extra-deps: []
# Override default flag values for local packages and extra-deps
# flags: {}
# Extra package databases containing global packages
# extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=1.7"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
md5-a8f176e5be48c6e7515496641f43c9b7
test/diagTest | cat src/Lib.hs | 12:32 PM
module Lib
( someFunc
) where
import Diagrams.Prelude
someFunc :: IO ()
someFunc = putStrLn "someFunc"
md5-aa1b508a1efb163749abf770151dea50
test/diagTest | stack build | 12:32 PM
haskeline-0.7.4.2: unregistering (Switching to snapshot installed package)
Building all executables for `diagTest' once. After a successful build of all of them, only specified executables will be rebuilt.
diagTest-0.1.0.0: configure (lib + exe)
Configuring diagTest-0.1.0.0...
diagTest-0.1.0.0: build (lib + exe)
Preprocessing library for diagTest-0.1.0.0..
Building library for diagTest-0.1.0.0..
[1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0/build/Lib.o )
/home/doyougnu/test/diagTest/src/Lib.hs:5:1: error:
Could not find module ‘Diagrams’
Use -v to see a list of the files searched for.
|
5 | import Diagrams
| ^^^^^^^^^^^^^^^
-- While building custom Setup.hs for package diagTest-0.1.0.0 using:
/home/doyougnu/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0 build lib:diagTest exe:diagTest-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
md5-998d0385810b4ca370e82271002921b7
~/test | stack --version | 12:24 PM
Version 1.7.0, Git revision 1d2f4e87142c8ca751c7d08161fa7a9d8232ff2e x86_64 hpack-0.21.2
pacman -S stackFixed. This is not a stack issue but is diagrams specific. The fix is silly and simple, one must enumerate all the diagram sub-libraries like so:
dependencies:
- base >= 4.7 && < 5
- diagrams
- diagrams-lib
- diagrams-contrib
- diagrams-svg
- diagrams-core
For anyone else who stumbles across this see this discussion
Most helpful comment
Fixed. This is not a stack issue but is
diagramsspecific. The fix is silly and simple, one must enumerate all the diagram sub-libraries like so:For anyone else who stumbles across this see this discussion