-
Notifications
You must be signed in to change notification settings - Fork 698
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
Add package-db flag for v2 commands #7676
Conversation
c5b589c
to
97cec49
Compare
@patrickdoc thanks for the pr, i will ping @phadej as he opened the original issue |
Oooh this will be useful for debugging #7270 |
97cec49
to
22e3897
Compare
Out of curiosity how this interacts with the V2 store package-db? is it cleared with |
I think that package-db stack should be recorded in package hashes. This patch doesn't seem to include changes there. EDIT: yes, it very much should be recorded, as otherwise store will look broken, as it will refer to units in package-db which you don't know about. ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most importantly, this lacks documentation.
Out of curiosity how this interacts with the V2 store package-db?
Is important question to answer, in particular.
My understanding/expectation is that it interacts as described above -- i.e., cabal will provide the packages in the store following the package-db stack, just as it does with the default stack? Let's think through the hash case closely. Suppose I have I think its worth testing first to be sure that this path doesn't somehow work, but I also understand very much the concern here. I'd also like to figure out where the documentation goes? The flag is already listed in the "Setup.hs flags" section of the docs, which is where most similar flags that cabal-install accepts but are passed to the underlying Setup are listed. (Ah -- maybe the cabal.project section as well!) |
My comment to include package db stack in hashes of packages will render that scenario impossible. In cases when there are additional package-db and aren't, hashes of In simple: package hash should record all dependencies and configurations. Package-db stack is a dependency/configuration. |
Right -- I was just trying to both fully express what the precise bad outcome could be and also expressing a question as to whether that outcome would occur or not -- i.e. would the hash actually need to be changed, or is it possible that things would work without it. Note that changing the hash can be problematic (without careful attention to backwards compat) because a simple cabal-install version bump could wind up invalidating an entire store. |
The goal was to stick to the description provided by the current documentation:
Before the change, the PackageDB stack was (relevant code in ProjectPlanning elaboration): After the change, the PackageDB stack is: Where My tests are mostly based on the "read" aspect of picking up available packages from alternative stores as opposed to the "write" aspect of where they go when they are built. I'll work on clearing up what happens in the store. Any thoughts on where you'd like the docs to be once that is worked out? |
@patrickdoc I think the "cabal.project" section of the documentation could have the flag (as that also has v2 opts) as well, rather than just the Setup.hs section. Another thought could be that we could enable this flag just with build and not with install, which would bypass the issue of the store hashes in a very straightforward way, and might still suffice for all the intended use cases? |
thanks for the info, it is very useful indeed, I still miss the place of the store package db in that picture |
I've been researching the packageDB and store, and I'm not sure I understand the model well enough to implement a valid + satisfying solution. Here's a hypothetical situation: Package in Store, but not in Package-DBReproducer:
I get this failure:
I see the options as:
My understanding of the model is that 3 is theoretically acceptable. A hash should uniquely define a build of a package. So if I have a build that matches my expectations, it would be safe to use it. If that is true, then we technically wouldn't need to change the hash with different package-db stacks, and the store could be shared. If it is not true, then we lose out on a reasonable large sharing opportunity. But perhaps the use case is small enough that we don't really care about taking advantage of this possibility. |
2e04e3f
to
7c24f7c
Compare
Requested changes are complete:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
doc/cabal-project.rst
Outdated
PATH | ||
Absolute path to a packageDB. | ||
|
||
With Nix-style local builds, the default package DB stack is ``[global, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you uses --package-db
, could not you specify the <compiler store>
as one of the pieces of the stack? is it included always by default? or you have to set it explicitly with the path if you want it to be included?
I would include a note in docs to make clear what happens with it if you uses the flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would change <compiler store>
with <cabal store>
as that package db is created and used by cabal. to distinguish it from the global, which is tied to the compiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the change, the PackageDB stack was (relevant code in ProjectPlanning elaboration):
[CompilerDB, InplaceDB]
After the change, the PackageDB stack is:
[CompilerDB, , InplaceDB]
If this is still up to date could be used as a model to add the note i miss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried to keep this relatively concise, but using my computer (debian) as an example:
global
: ~/.ghcup/ghc/8.10.7/lib/ghc-8.10.7/package.conf.d
user
: not defined
store: ~/.cabal/store/ghc-8.10.7/package.db
in-place: ./dist-newstyle/packagedb/ghc-8.10.7
By default, the package stack you will have with v2 commands is:
[global, store]
So all remote packages required by your project will be registered in the store package db (because it is last).
When cabal starts building your local projects, it appends the in-place db to the end:
[global, store, in-place]
So your local packages get put in dist-newstyle instead of the store.
This flag manipulates the default prefix:
[global, store]
To more directly answer your questions:
- yes, you can specify the store package db with:
--package-db /home/patrick/.cabal/store/ghc-8.10.7/package.db
- yes, it is included by default
The main tricky bit is the clear
option, which removes all previous entries. Ex.
--p-db foo
-> [global, store, foo]
--p-db clear --p-db foo
-> [foo]
--p-db clear --p-db foo --p-db clear --p-db bar --p-db baz
-> [bar, baz]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, that is a great explanation, imo it deserves be included in docs including the super useful final examples, would you mind do it in this pr as you have it almost written?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Just under the flag description or a more general place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the flag description sounds good to me, it is a somewhat advanced stuff and useful for someone who already wants to tweak seminternal things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@phadej: I'm guessing your comments have been addressed sufficiently and so I will take the liberty of dismissing the review blockage, as per usual, unless you object. Thank you once again for your insight! |
@@ -38,7 +38,7 @@ module Distribution.Simple.Setup ( | |||
GlobalFlags(..), emptyGlobalFlags, defaultGlobalFlags, globalCommand, | |||
ConfigFlags(..), emptyConfigFlags, defaultConfigFlags, configureCommand, | |||
configPrograms, | |||
configAbsolutePaths, readPackageDbList, showPackageDbList, | |||
configAbsolutePaths, readPackageDb, readPackageDbList, showPackageDb, showPackageDbList, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add @SInCE annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
7c24f7c
to
6f85836
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the pr and for addressing my suggestions, looks really great
@fgaz: have your comments been addressed? Dear all, should we merge? |
Yes, let's merge! |
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!
This PR teaches v2-* commands how to use the
--package-db
flag (#5773). The records were already present in the config types, just commented out. I've un-commented them and injected the values into the two places they were needed (initial plan and elaboration).TODO:
The added tests cover:
--package-db=xyz
)--package-db=clear
)--package-db=clear --package-db=global --package-db=xyz
)