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

doctest is broken with ghc 8.8.1/cabal 3.0 (?) #245

Open
googleson78 opened this issue Oct 21, 2019 · 5 comments
Open

doctest is broken with ghc 8.8.1/cabal 3.0 (?) #245

googleson78 opened this issue Oct 21, 2019 · 5 comments
Labels
v2-cabal Concerning v2-style cabal commands

Comments

@googleson78
Copy link

googleson78 commented Oct 21, 2019

There seems to be some difference in behaviour, perhaps what environment is sought for packages?? I honestly have no idea.

I am asking here in case someone is aware of such a (potential) problem.

Repro:

  1. Have cabal 3.0 + ghc 8.8.1
  2. git clone [email protected]:isovector/type-errors.git
  3. git checkout f171628f607d83de18bd96c1d4247674fece6b15 (current master)
  4. cabal v2-test
Output

Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
 - type-errors-0.2.0.0 (test:test) (first run)
Preprocessing test suite 'test' for type-errors-0.2.0.0..
Building test suite 'test' for type-errors-0.2.0.0..
Running 1 test suites...
Test suite test: RUNNING...
test: <command line>: cannot satisfy -package first-class-families
    (use -v for more information)
Test suite test: FAIL
Test suite logged to:
/home/googleson78/git/type-errors/dist-newstyle/build/x86_64-linux/ghc-8.8.1/type-errors-0.2.0.0/t/test/test/type-errors-0.2.0.0-test.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:test from type-errors-0.2.0.0.

@googleson78 googleson78 changed the title doctest is broken with cabal 3.0 (?) doctest is broken with ghc 8.8.1/cabal 3.0 (?) Oct 21, 2019
@travitch
Copy link

For whatever it is worth, I'm also seeing these failures with cabal 3.0 and ghc 8.6.5

@quasicomputational
Copy link
Collaborator

Yeah, doctest itself doesn't know about where various build tools put package databases - it punts to GHC, which in turn checks some environment variables. The best solution for now would be asking upstream to use cabal-doctest, which is a hack that does the necessary wiring-up in a build-tool-independent manner; a cabal-install solution is to use cabal v2-exec to invoke doctest, which sets the appropriate environment variables.

hasufell added a commit to hasufell/hpath that referenced this issue Dec 30, 2019
This fixes various problems with doctest:

* sol/doctest#245
* composewell/streamly#83

Also clean up travis.yml for cabal-3.
hasufell added a commit to hasufell/hpath that referenced this issue Dec 30, 2019
This fixes various problems with doctest:

* sol/doctest#245
* composewell/streamly#83

Also clean up travis.yml for cabal-3.
@travitch
Copy link

travitch commented Feb 7, 2020

A coworker clued me in to my problem: cabal 3.0 no longer creates the GHC environment files by default (cabal 2.0 did). If I build my project with --write-ghc-environment-files=always, my doctests are able to find the packages they import. I ended up putting this in my ~/.cabal/config to set it globally.

@simonmichael
Copy link

simonmichael commented Mar 7, 2020

@travitch, thanks for that. Some more notes:

  • you can put write-ghc-environment-files: always in your project's cabal.project file
  • cabal 2 won't understand that, but it's just a warning so shouldn't stop it
  • cabal 3 will generate the .ghc.environment* file, but the first run of a doctest suite will still fail; the second run will succeed. Hopefully in practice cabal build will generate the file in time for the test suite.

@TomMD
Copy link

TomMD commented Mar 25, 2020

Using ghc environment files is a good way to get further. It results in doctest knowing where to find the packages. We still need doctest to only use the packages of interest for a given build unit or else it has trouble with duplicate modules.

As an example, this problem is observable when you have crypto-api and cryptonite installed then import Crypto.Random.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2-cabal Concerning v2-style cabal commands
Projects
None yet
Development

No branches or pull requests

6 participants