Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules not found when installed via Nix #7

Open
YPares opened this issue Nov 23, 2015 · 6 comments
Open

modules not found when installed via Nix #7

YPares opened this issue Nov 23, 2015 · 6 comments

Comments

@YPares
Copy link

YPares commented Nov 23, 2015

Hi,
when trying to run the example, I get:

Error while interpreting
example = circle 1
/tmp/Diagram1804289383846930886.hs:4:8:
    Could not find module ‘Diagrams.Prelude’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:5:8:
    Could not find module ‘Diagrams.TwoD.Types’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:6:8:
    Could not find module ‘Diagrams.Core.Points’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:7:8:
    Could not find module ‘Diagrams.Backend.Cairo’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:8:8:
    Could not find module ‘Diagrams.Backend.Cairo.Internal’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:9:8:
    Could not find module ‘Graphics.SVGFonts’
    Use -v to see a list of the files searched for.

whereas when I run ghci manually, I can import Diagrams.Prelude without any problem.

(I installed GHC, pandoc and diagrams-pandoc through Nix, but as I said, ghci has no problem finding the required modules)

@YPares YPares changed the title Error while interpreting Error while interpreting (modules not found) Nov 23, 2015
@bergey bergey changed the title Error while interpreting (modules not found) modules not found when installed via Nix Nov 23, 2015
@bergey
Copy link
Member

bergey commented Nov 23, 2015

Can you be more specific about how you installed these things? Is it like nix-env -i or do you have some nix-shell environment within which the packages are in scope?

I think I used to have a shell.nix file that loaded all the necessary packages, within which I could run diagrams-pandoc. Getting HSE and Nix to work together is always tricky, though.

@YPares
Copy link
Author

YPares commented Nov 24, 2015

I tried both. Both the nix-shell and the installation with nix-env -i had the same issue.
But ideally I'd like to use it through a nix-shell, like you did, yes.

@bergey
Copy link
Member

bergey commented Nov 25, 2015

OK, thank you for clarifying. I'll dust off my .nix files and add an
example of Nix usage. I probably won't get to it before Sunday.

On 2015-11-24 at 12:49, "Yves Parès (Ywen)" notifications@github.com wrote:

I tried both. Both the nix-shell and the installation with nix-env -i had
the same issue.
But ideally I'd like to use it through a nix-shell, like you do, yes.

2015-11-23 22:55 GMT+01:00 Daniel Bergey notifications@github.com:

Can you be more specific about how you installed these things? Is it like nix-env
-i or do you have some nix-shell environment within which the packages
are in scope?

I think I used to have a shell.nix file that loaded all the necessary
packages, within which I could run diagrams-pandoc. Getting HSE and Nix to
work together is always tricky, though.


Reply to this email directly or view it on GitHub
#7 (comment)
.


Reply to this email directly or view it on GitHub:
#7 (comment)

@epsilonhalbe
Copy link

I experience the same thing with stack/cabal sandbox - I've created a new user and used per user global cabal install - then it worked

@alsam
Copy link

alsam commented Dec 21, 2015

I've stumbled upon the same problem:

Error while interpreting
example = circle 1
/tmp/Diagram1804289383846930886.hs:9:8:
    Could not find module Graphics.SVGFonts
    Use -v to see a list of the files searched for.

but after cabal install SVGFonts - details on the package are here:
http://hackage.haskell.org/package/SVGFonts
the problem has been resolved for me - even succeeded in producing .pdf file with
pandoc -t latex diagrams_pandoc_example.md --filter diagrams-pandoc -o diagrams_pandoc_example.pdf -s
You might need to install other additional packages via cabal, say diagrams.

@edwtjo
Copy link

edwtjo commented Sep 28, 2016

Since this is still open; I use the following shell.nix and it correctly detects the libraries, i.e. you just need to wrap diagrams-pandoc. I typically do nix-env -i -f shell.nix && nix-shell to invoke it.

with (import (fetchTarball
  https://github.com/NixOS/nixpkgs/archive/2a83412f2a15a6eb416473a37140fe9d9fac8e3b.tar.gz){}).pkgs;
let
  ext = self: with self; [ diagrams diagrams-contrib diagrams-pandoc pandoc SVGFonts ];
  wrappedGhc = haskell.packages.lts-5.ghcWithPackages ext;
  ghcVersion = wrappedGhc.version;
in
stdenv.mkDerivation rec {
  pname = "DPENV";
  version = "0.1";
  name = pname + "-" + version;
  buildInputs = [ makeWrapper ];
  phases = [ "installPhase" ];
  installPhase = ''
    mkdir -p $out/bin
    makeWrapper \
      "${wrappedGhc}/bin/diagrams-pandoc" \
      "$out/bin/diagrams-pandoc" \
        --set NIX_GHC ${wrappedGhc}/bin/ghc \
        --set NIX_GHC_LIBDIR ${wrappedGhc}/lib/ghc-${ghcVersion}
  '';
  shellHook = ''
    export PS1="DP > "
  '';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants