Skip to content

Assertion failure with --package-db flag #9678

Closed
@mpickering

Description

If you specify the --package-db flag then you get an assertion failure whenever cabal attempts to build a package which should end up in the store.

Repro: https://github.com/mpickering/cautious-octo-spoon

The assertion checks whether the elabRegisterPackageDBStack is the same as storePackageDBStack, which they are not because the elabRegisterPackageDBStack contains the --package-db flag.

The reason for this difference is that in ProjectPlanning.hs computes corePackageDbs as follows:

2318       corePackageDbs =                                                          
2319         applyPackageDbFlags                                                     
2320           (storePackageDBStack compiler)                                        
2321           (projectConfigPackageDBs sharedPackageConfig)  

Notice that the project config package db flags are applied after the store package db paths (this seems wrong to me).

Things only don't go horribly wrong because in the next bit of code storePackageDBStack is used to decide where to register the package rather than elabRegisterPackageDBStack.

In order to understand how to fix this assertion it's necessary to decide on the specification of the --package-db flag.

My understanding of how I want it to work is that --package-db flag specifies an immutable package database which augments the global store with some additional packages. We do not under any circumstances want to register packages into a package database provided by --package-db.

cabal-install mutates two package databases:

  • The store directory
  • The inplace directory

Therefore these should always appear after the package database provided by --package-db so that when a package is registered it's registered into one of these two places rather than anything the user provides with --package-db.

This also has the consequence that packages in the store can depend on --package-db packages, but not vice-versa, which I believe is also the intention of the flag.

Flag introduced in : #7676

In the documentation it states that the order is intentional but I don't think that makes much sense:


    This flag manipulates the default prefix: ``[global, store]`` and accepts
    paths, the special value ``global`` referring to the global package db, and
    ``clear`` which removes all prior entries. For example,

    ::

        -- [global, store, foo]
        package-dbs: foo

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions