You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cabal new-install, environment files, and unsolvable constraints #5559
Because new-install wants to keep every package that GHC bundles in the environment, it adds every package from this list to the environment along with the initial targets. Unfortunately, this can create environments that, when read back in, are not actually valid solved package sets, because (e.g.) Cabal is happy to pick a newer version of directory that is incompatible with the current ghc's dependency, and then create an environment that references both this newer directory version and the ghc library version that it cannot be used with, and further calls to new-install will fail because of this.
In addition, it does not correctly remove constraints on older versions of the target library, so if (e.g.) semigroups-0.18.4 has been new-installed and one attempts to install semigroups-0.18.5, this will also conflict because there is a hard constraint on the previous semigroups version.
Reacted by Daniel Gröber (dxld), Thomas M. DuBuisson and rosshjb
start with a notional package that depends on all the default libraries based on compiler version (can just look at global package env? maybe)
each new-install --lib is isomorphic to adding a new dependency to this package and then updating what we track, with same errors as normal if you try to add an unsolvable dependency to a package.
I've just been bitten by this. cabal v2-install claimed that directory-1.3.4.0 was a user goal (which is false) and that directory-1.3.4.0 conflicts with the one that came with my GHC (which is true). Deleting the entry for directory-1.3.4.0(and several others) in my .ghc/<version>/environments/default allowed me to v2-install successfully. On the other hand the offending lines were recreated by that command!
Could someone please explain to me how those lines got there? Is cabal putting them there or is ghc putting them there as a consequence of how cabal calls it?
I'm not sure what the options are for a smooth universal solution... some brainstorming:
Status quo (ugh)
A new environment per project. Pretty sure this was a default for a moment in time but people didn't like ghci giving a different environment without warning and based on the CWD.
A nicer error message that says the conflict is due to an environment and how to either remove the default (and that doing so is safe) or use a new environment.
@typedrat's proposal where cabal try's to solve using the current environment as constraints.
I'm in favor of some combination of the last two. Are there other apparent options out there to consider?
I don't understand why this is tagged blocked: info-needed. Can someone explain what info is needed or remove the tag? I'm the filer of 6342 which is marked a duplicate of this. BTW this appears as a regression to me since cabal v1-install works, see 6342
So I was thinking about this, specifically about how to store the dependencies/targets and both the two possible file-based solutions have downsides:
storing it centrally needs gc and can cause problems if the user manually edits an env file
storing it in a separate file in the same directory as the env file is just messy -- I already have enough config files
But then I realized there's a third way, which may have been obvious, but I don't see any mention of it in this thread so I'm writing it down for reference:
store the info in a comment in the environment file (yes, they support comments too, fortunately).
Here's a sketch of what this would require:
adding a CabalTargets [TargetSelector] (or similar) constructor to the GhcEnvironmentFileEntry datatype
reading the comment before installing (and maybe falling back on the current behavior if the file is not cabal-generated) and using that as additional targets instead of using the env file contents
making cli targets with the same name override the ones from the file (for example semigroups-0.18.5 from cli overrides semigroups-0.18.4 from the comment)
being explicit about that: "Warining: Overwriting package x-x.y with x-X.Y"
writing the (merged) targets to the comment when installing on an environment file (MAYBE only if it's a new env or if it's cabal-generated (=it already has the comment))
also writing a brief explanation ("the following comment contains...") in a comment
printing lots of info about what cabal is doing ("adding targets to env file /home/foo/.ghc/...", "using targets x y and x from env file", etc)
From my experience with cabal-env, you not only want to store [TargetSelector] but also:
explicitly hidden packages (e.g. to hide base-compat where you have base-compat-batteries)
I.e. you need a way to also hide some packages.
Which leads to design question: should only explicitly selected be visible? I think so. But then adding stuff (which is already there) should be fast: Then you'd need to store plan.json too, so you don't need to resolve every environment modification operation: if the new target is already there (transitively): just enable it.
EDIT: I realise if you only make specifically requested packages public, you don't need to store the list of hidden packages. But you still want a faster regeneration, when they are in plan.
@hvr You tagged this "blocked: info-needed" and then wrote "this needs to have a solution/algorithm/heuristic designed to proceed". I thought "blocked: info-needed" was reserved for issues that needed info to reproduce. If it is used for all bugs without a solution wouldn't there by many more tagged "blocked: info-needed"? In any case your comment is a year old now, it would be nice if somebody could design a solution/algorithm/heuristic to proceed. I'm surprised cabal 3.0 was released with this bug.
On Thu, Nov 21, 2019 at 10:07 AM Oleg Grenrus ***@***.***> wrote:
I removed the blocked: info-needed. The issue is well understood.
Software has bugs, some are fixed on time, some aren't. This is bad, but
not critical, that the release could been postponed.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5559?email_source=notifications&email_token=ABQIJ642ACY7W6BA3RRC2U3QU2IYJA5CNFSM4FSZSMLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2KWIY#issuecomment-557099811>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQIJ636QOXQ7NXEJMMKCDLQU2IYJANCNFSM4FSZSMLA>
.
And if we look at the environment file, it's what we'd expect there to be.
Additional state is stored in the comments, with a last plan.json (lzma'd
and base64 encoded)
Activity
hvr commentedon Oct 1, 2018
this needs to have a solution/algorithm/heuristic designed to proceed
typedrat commentedon Oct 26, 2018
Consider a sketch of a solution:
new-install --libis isomorphic to adding a new dependency to this package and then updating what we track, with same errors as normal if you try to add an unsolvable dependency to a package.23Skidoo commentedon Jul 23, 2019
For 3.0, maybe we should add a warning to
install --libthat it's somewhat experimental for now?tomjaguarpaw commentedon Oct 26, 2019
I've just been bitten by this.
cabal v2-installclaimed thatdirectory-1.3.4.0was a user goal (which is false) and thatdirectory-1.3.4.0conflicts with the one that came with my GHC (which is true). Deleting the entry fordirectory-1.3.4.0(and several others) in my.ghc/<version>/environments/defaultallowed me tov2-installsuccessfully. On the other hand the offending lines were recreated by that command!Could someone please explain to me how those lines got there? Is
cabalputting them there or isghcputting them there as a consequence of howcabalcalls it?TomMD commentedon Nov 8, 2019
This is perhaps the most common Haskell gotcha I walk though with my new devs and people from afar (such as here https://stackoverflow.com/questions/58755666/haskell-install-puremd5-package/58759535#58759535).
I'm not sure what the options are for a smooth universal solution... some brainstorming:
I'm in favor of some combination of the last two. Are there other apparent options out there to consider?
gbaz commentedon Nov 8, 2019
At least 3 should occur. I think some of the
cabal-envstuff (https://github.com/phadej/cabal-env) is sort of supposed to prototype some workflows for 4?GeorgeCo commentedon Nov 13, 2019
I don't understand why this is tagged blocked: info-needed. Can someone explain what info is needed or remove the tag? I'm the filer of 6342 which is marked a duplicate of this. BTW this appears as a regression to me since cabal v1-install works, see 6342
fgaz commentedon Nov 20, 2019
So I was thinking about this, specifically about how to store the dependencies/targets and both the two possible file-based solutions have downsides:
But then I realized there's a third way, which may have been obvious, but I don't see any mention of it in this thread so I'm writing it down for reference:
Here's a sketch of what this would require:
CabalTargets [TargetSelector](or similar) constructor to theGhcEnvironmentFileEntrydatatypephadej commentedon Nov 20, 2019
From my experience with
cabal-env, you not only want to store[TargetSelector]but also:base-compatwhere you havebase-compat-batteries)I.e. you need a way to also hide some packages.
Which leads to design question: should only explicitly selected be visible? I think so. But then adding stuff (which is already there) should be fast: Then you'd need to store
plan.jsontoo, so you don't need to resolve every environment modification operation: if the new target is already there (transitively): just enable it.EDIT: I realise if you only make specifically requested packages public, you don't need to store the list of hidden packages. But you still want a faster regeneration, when they are in plan.
GeorgeCo commentedon Nov 21, 2019
@hvr You tagged this "blocked: info-needed" and then wrote "this needs to have a solution/algorithm/heuristic designed to proceed". I thought "blocked: info-needed" was reserved for issues that needed info to reproduce. If it is used for all bugs without a solution wouldn't there by many more tagged "blocked: info-needed"? In any case your comment is a year old now, it would be nice if somebody could design a solution/algorithm/heuristic to proceed. I'm surprised cabal 3.0 was released with this bug.
phadej commentedon Nov 21, 2019
I removed the
blocked: info-needed. The issue is well understood.Software has bugs, some are fixed on time, some aren't. This is bad, but not critical, that the release could been postponed.
GeorgeCo commentedon Nov 21, 2019
phadej commentedon Nov 22, 2019
I prototyped a variant along @fgaz comment in
cabal-env(debug messages show how long the commands take to run)Let's install
someWe can check what's in the environment:
Next we can try to install
someagain, and also specify thatonly targets are exposed:
Let's install another package,
semialigndoesn't depend onsome,but both are in the environment:
We realise that we also need
theseto use withsemialign, let's quicklyadd it:
And if we look at the environment file, it's what we'd expect there to be.
Additional state is stored in the comments, with a last
plan.json(lzma'dand base64 encoded)
Use cabal-env
travis: use --upgrade-dependencies