jfeltz / dash-haskell

dash docset builder for Haskell packages and cabal project dependencies
GNU Lesser General Public License v3.0
79 stars 12 forks source link

Using dash-haskell with stack #14

Open bts opened 9 years ago

bts commented 9 years ago

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!

jfeltz commented 9 years ago

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

jfeltz commented 9 years ago

Let me know if the latest commit works for you.

bts commented 9 years ago

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 commented 9 years ago

Ah it seems like stack exec is probably setting GHC_PACKAGE_PATH?

jfeltz commented 9 years ago

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).

mohanzhang commented 9 years ago

@bts Were you ever able to get it working?

drwebb commented 9 years ago

@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.

mohanzhang commented 9 years ago

@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.

olivierverdier commented 6 years ago

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

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

adamczykm commented 6 years ago

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!