Skip to content

"Conflicting family instance declaration" error with same type/definition #4705

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

Open
parsonsmatt opened this issue Apr 5, 2019 · 4 comments

Comments

@parsonsmatt
Copy link
Contributor

Please follow the steps below for reporting a bug:

General summary/comments (optional)

Steps to reproduce

$ git clone [email protected]:yesodweb/persistent
$ cd persistent
$ git checkout matt/stack-build-error
$ stack build --test --no-run-tests --fast

Expected

ExitSuccess, or at least an actual error.

Actual

λ ~/Projects/persistent/ matt/stack-build-error stack build --fast --test --no-run-tests
persistent-mongoDB-2.8.0: unregistering (local file changes: test/MongoInit.hs)
persistent-test-2.0.2.0: unregistering (missing dependencies: persistent-mongoDB)
persistent-2.9.2: Test running disabled by --no-run-tests flag.
persistent-mongoDB-2.8.0: configure
persistent-redis-2.5.2.2: Test running disabled by --no-run-tests flag.
persistent-sqlite-2.9.2: Test running disabled by --no-run-tests flag.
persistent-template-2.6.0: Test running disabled by --no-run-tests flag.
persistent-mongoDB-2.8.0: build
persistent-mongoDB-2.8.0: copy/register
persistent-test-2.0.2.0: configure (lib + exe)
persistent-test-2.0.2.0: build (lib + exe)
persistent-test-2.0.2.0: copy/register
persistent-mongoDB-2.8.0: configure (test)
persistent-mongoDB-2.8.0: build (test)
persistent-qq-2.9.1: configure (test)
persistent-qq-2.9.1: build (test)
persistent-qq-2.9.1: Test running disabled by --no-run-tests flag.
Log files have been written to: /home/matt/Projects/persistent/.stack-work/logs/
Progress 9/10

--  While building package persistent-mongoDB-2.8.0 using:
      /home/matt/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --
builddir=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1 build test:test --ghc-options " -ddump-hi
-ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/matt/Projects/persistent/.stack-work/logs/persistent-mongo
DB-2.8.0.log

    Configuring persistent-mongoDB-2.8.0...
    Preprocessing library for persistent-mongoDB-2.8.0..
    Building library for persistent-mongoDB-2.8.0..
    [1 of 1] Compiling Database.Persist.MongoDB ( Database/Persist/MongoDB.hs, .stack-work/dist
/x86_64-linux/Cabal-2.4.0.1/build/Database/Persist/MongoDB.o )
    Preprocessing test suite 'test' for persistent-mongoDB-2.8.0..
    Building test suite 'test' for persistent-mongoDB-2.8.0..
    [1 of 4] Compiling MongoInit        ( test/MongoInit.hs, .stack-work/dist/x86_64-linux/Caba
l-2.4.0.1/build/test/test-tmp/MongoInit.o )

    /home/matt/Projects/persistent/persistent-mongoDB/test/MongoInit.hs:1:1: error:
        Conflicting family instance declarations:
          BackendKey MongoDB.MongoContext
            -- Defined in ‘Database.Persist.MongoDB’
          BackendKey MongoDB.MongoContext
            -- Defined in ‘persistent-mongoDB-2.8.0:Database.Persist.MongoDB’
      |
    1 | {-# LANGUAGE ScopedTypeVariables #-}
      | ^

    /home/matt/Projects/persistent/persistent-mongoDB/test/MongoInit.hs:1:1: error:
        Conflicting family instance declarations:
          BackendSpecificFilter
            MongoDB.MongoContext record = Database.Persist.MongoDB.MongoFilter
                                            record
            -- Defined in ‘Database.Persist.MongoDB’
          BackendSpecificFilter
            MongoDB.MongoContext
            record = persistent-mongoDB-2.8.0:Database.Persist.MongoDB.MongoFilter
                       record
            -- Defined in ‘persistent-mongoDB-2.8.0:Database.Persist.MongoDB’
      |
    1 | {-# LANGUAGE ScopedTypeVariables #-}
      | ^

    /home/matt/Projects/persistent/persistent-mongoDB/test/MongoInit.hs:1:1: error:
        Conflicting family instance declarations:
          BackendSpecificUpdate
            MongoDB.MongoContext record = Database.Persist.MongoDB.MongoUpdate
                                            record
            -- Defined in ‘Database.Persist.MongoDB’
          BackendSpecificUpdate
            MongoDB.MongoContext
            record = persistent-mongoDB-2.8.0:Database.Persist.MongoDB.MongoUpdate
                       record
            -- Defined in ‘persistent-mongoDB-2.8.0:Database.Persist.MongoDB’
      |
    1 | {-# LANGUAGE ScopedTypeVariables #-}
      | ^

The location it gives are for the exact same place. It would appear that the test-suite is somehow gaining privileged access to the Database.Persist.MongoDB module. Removing the dependency in the cabal file does not fix the problem - instead, we get an error where the module is not available to import.

Gist with the command run with --verbose

Stack version

λ ~/Projects/persistent/ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpa
ck-0.31.1

Method of installation

  • Fresh upgrade via stack upgrade
@parsonsmatt
Copy link
Contributor Author

Note that this is a "cyclic" dependency:

  • persistent-mongoDB:test depends on
  • persistent-test:lib depends on
  • persistent-mongoDB:lib

Could that be the reason for this?

@dbaynard
Copy link
Contributor

dbaynard commented Apr 6, 2019

Could that be the reason for this?

Yes, it very well could. Cyclic dependencies are not supported in this manner in 1.9.3. I believe they may be supported on master (with the changes to the component-based build). Would you be able to try that?

@qrilka
Copy link
Contributor

qrilka commented Apr 7, 2019

@dbaynard maybe I'm wrong here but I don't think we have proper component-based builds in Stack yet (though I think that it should help us with some issues).

@parsonsmatt
Copy link
Contributor Author

Seems like a description of what's going on is in this comment!

#2583 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants