Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use "cabal-dev ghci" with a non-sandbox, non-global (user?) package?
    primarykey
    data
    text
    <p>I'm trying out <code>cabal-dev</code> for a project I'm working on; the project is a library, and <code>cabal-dev</code> does a great job of building a sandboxed version of it - but I'm having trouble with part of my workflow...</p> <p>I have a script, <code>scratch.hs</code>, which (pre-<code>cabal-dev</code>) I would load into <code>ghci</code> for trying stuff out. The contents of <code>scratch.hs</code> change over time depending on what feature I'm working on, of course. <code>scratch.hs</code> isn't part of the library codebase, it's just my personal scratchspace while I'm working on it.</p> <p>Now, in order to get a <code>ghci</code> session with my sandbox loaded, I can just <code>cabal-dev ghci</code>, and then load <code>scratch.hs</code> into that. The problem is that this (by design, and sensibly) excludes my user package database, so if <code>scratch.hs</code> references modules from packages which aren't in my library's <code>build-depends</code> (which is not unreasonable - it's not part of the library after all), those packages aren't visible, and so I get an error such as:</p> <pre><code>scripts/scratch.hs:8:8: Could not find module `Data.Aeson.Generic': It is a member of the hidden package `aeson-0.3.2.11'. Perhaps you need to add `aeson' to the build-depends in your .cabal file. Use -v to see a list of the files searched for. Failed, modules loaded: none. </code></pre> <p>where, in this case, <code>scratch.hs</code> wants to import <code>Data.Aeson.Generic</code> but <code>aeson</code> is not in my library's <code>build-depends</code> (quite properly), but <em>is</em> in my user package database.</p> <p>So how can I work around this? I can imagine answers in either of these categories, but maybe there are categories I've missed:</p> <ol> <li><p>A way to (selectively) use packages from my user package database in conjunction with the sandbox created by <code>cabal-dev</code>. (Perhaps rolling my own <code>cabal-dev ghci</code> style script?)</p></li> <li><p>A suggestion on how to improve my workflow so the problem just goes away.</p></li> </ol> <p>I know I could just install the package globally, but I'm reluctant to pollute my global package database in this manner (and <code>cabal-dev</code> discourages this explicitly).</p> <p>Many thanks for all advice.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload