dash-haskell icon indicating copy to clipboard operation
dash-haskell copied to clipboard

Using dash-haskell with stack

Open bts opened this issue 10 years ago • 10 comments
trafficstars

Hi there,

I'm trying to use dash-haskell with stack:

$ stack exec -- dash-haskell -c foo.cabal --db /Users/bts/.stack/snapshots/x86_64-osx/nightly-2015-07-15/7.10.1/pkgdb
using package db stack:
 > ghc distribution (global db)
 > system user
 > db directory: /Users/bts/.stack/snapshots/x86_64-osx/nightly-2015-07-15/7.10.1/pkgdb

dash-haskell: ./cabal.sandbox.config: openFile: does not exist (No such file or directory)

Does dash-haskell currently require the use of sandboxes to function, or is there a command line option I should supply to prevent the attempt to read ./cabal.sandbox.config?

Thanks!

bts avatar Jul 17 '15 20:07 bts

It shouldn't require a sandbox to function. This is a huge bug. Thanks for reporting.

jfeltz avatar Jul 18 '15 01:07 jfeltz

Let me know if the latest commit works for you.

jfeltz avatar Jul 18 '15 02:07 jfeltz

Thanks John!

I'm using the 2015-07-19 stackage nightly, so I think I am using the latest commit when I now get the following error:

% stack exec -- dash-haskell -c foo.cabal --db /Users/bts/.stack/snapshots/x86_64-osx/nightly-2015-07-19/7.10.1/pkgdb
using package db stack:
 > ghc distribution (global db)
 > system user
 > db directory: /Users/bts/.stack/snapshots/x86_64-osx/nightly-2015-07-19/7.10.1/pkgdb

dash-haskell: user error (Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal. Use the flag --package-db to specify a package database (it can be used multiple times).)

FWIW I don't have the environment variable GHC_PACKAGE_PATH set.

I've tried playing around with the --ordering flag to get it to only use the supplied package DB (without a global or user DB), but I'm not having much luck.

Thanks again! Brian

bts avatar Jul 20 '15 18:07 bts

Ah it seems like stack exec is probably setting GHC_PACKAGE_PATH?

bts avatar Jul 20 '15 19:07 bts

Possibly. Right now dash-haskell uses cabal as its back-end for looking up databases, and I'm now considering putting in a fallback to a custom indexer similar to that used in 1.0.0.5. Try also dash-haskell-1.0.0.5 where this is the case (it doesn't use cabal).

jfeltz avatar Jul 20 '15 21:07 jfeltz

@bts Were you ever able to get it working?

mohanzhang avatar Sep 11 '15 17:09 mohanzhang

@mohazhang The current behavior is unchanged, if dash-haskell is still using cabal as a backend GHC_PACKAGE_PATH cannot be set, which is how stack selects its pkgdb for a build.

drwebb avatar Sep 11 '15 18:09 drwebb

@drwebb Ok, so if I understand you correctly, you are saying that there is a fundamental reason why dash-haskell can't work with stack, and that this reason is because cabal doesn't like the way stack selects its pkgdb? I took this interpretation and ended up using https://github.com/philopon/haddocset instead.

For anyone reading this, don't let your Dash dreams be... dashed! :) haddocset works great, but operates on a slightly different model. The idea is that you create a basic docset generated from your global pkgdb. If you are using stack, this should be a very small set of docs (for me it was 25 packages). You also have to build your application with haddocks in order for the packages to have documentation. The end result is something like:

# in your app's directory, e.g. your yesod app
mkdir dash
stack exec -- haddocset -t dash/output create
# ... looks a lot like the README for haddocset, so far so good
stack build --haddock
# ... takes a while to build all the docs, then
stack exec -- haddocset -t dash/output add /Users/mohanzhang/.stack/snapshots/x86_64-osx/lts-3.2/7.10.2/pkgdb/*.conf
# figure out your pkgdb path with `stack path`
# ... takes a while, and you can get errors for missing docs, but that's ok,
# because not everything inside your stack pkgdb has docs (only those that
# you built with stack haddock at some point or other)

You can then add the docset in Dash preferences. You may also want to edit dash/output.docset/Contents/Info.plist so that it has a nicer bundle name, like "My App's Docs" or something.

/cc @philopon Did I get this right? I seem to have a pretty nice docset in my Dash right now as a result, but haven't had time to check it fully. Thanks to you and @jfeltz for making these solutions. Way way better than googling for docs on hackage.

mohanzhang avatar Sep 11 '15 20:09 mohanzhang

@mohanzhang amazing 😲 This should really be part of the readme of haddocset.

EDIT: (well, nevermind, it is already part of the readme of haddocset...)

olivierverdier avatar Jan 05 '18 15:01 olivierverdier

Each time I'm calling stack exec wtih haddock I get a following error: haddock: internal error: /usr/lib/ghc-8.2.2/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) Do you know how can I resolve it? Thanks!

adamczykm avatar Mar 10 '18 22:03 adamczykm