Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell package installed but not found

I installed diagrams, and it seems to be there, but GHCi doesn’t find it. I tried adding the local sandbox to the command line (-package-db), but still no luck. Any suggestions?

   C:\Users\guthrie>
   C:\Users\guthrie>cabal install diagrams
    Resolving dependencies...
    All the requested packages are already installed:
   diagrams-1.2
   Use --reinstall if you want to reinstall anyway.

I find it in:

  C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
        (diagrams-1.2, diagrams-contrib, -core, -lib, -svg) 

But running: “cabal repl” or using the GHC(i) flag “-package-db=…” fail to find it:

C:\Users\guthrie>cabal repl
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Diagrams.Prelude

<no location info>:
    Could not find module `Diagrams.Prelude'
   It is not a module in the current program, or in any known package.
Prelude>

To clarify; ignoring the cabal invocations, using GHC/i directly, and the program diagramsDemo.hs:

--  http://projects.haskell.org/diagrams/doc/quickstart.html
--
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine

main = mainWith (circle 1 :: Diagram B R2)

Gives:

C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs

diagramsDemo.hs:7:8:
    Could not find module `Diagrams.Backend.SVG.CmdLine'
    Use -v to see a list of the files searched for.

C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs -package-db=C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d

diagramsDemo.hs:7:8:
    Could not find module `Diagrams.Backend.SVG.CmdLine'
    Use -v to see a list of the files searched for.
like image 963
guthrie Avatar asked Feb 20 '15 14:02

guthrie


People also ask

Where are Haskell packages installed?

If you don't need a fully partitioned GHC environment and are happy with the installed versions on DICE, cabal might be the simplest way to install the Haskell packages you require. By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.

Where does Stack install GHC?

You can find these sandboxed GHC installations in the ghc-* directories in the stack path --programs directory. If you would like Stack to use your system GHC installation, use the --system-ghc flag or run stack config set system-ghc --global true to make Stack check your PATH for a suitable GHC by default.


1 Answers

As bheklilr said, if ghci is started with cabal repl, it will only find packages specified as a dependency in the .cabal file.

However you can start it with cabal exec ghci, then it will find all packages installed in the sandbox.

The same is true for invoking ghc (cabal build vs. cabal exec ghc), but note that if you want to pass flags you have to use --, like in cabal exec ghc -- -O2 Main.hs. Alternatively you can use cabal exec bash and launch ghci or ghc in the new shell.

cabal exec was added with Cabal 1.20.

like image 122
ipsec Avatar answered Oct 21 '22 12:10

ipsec