-
Notifications
You must be signed in to change notification settings - Fork 701
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
cabal build
error, don't warn and fallback to older state.
#8076
Comments
If on line 279, I change
|
I think the codebase uses |
Anyway, is anybody opposed to this change? Can we think of a workflow it breaks? Should it be an option turned on by a flag somewhere? |
Here's the behaviour with
|
@Mikolaj These commands call If we change the message, could we mention the command? In the example I use "this command" because at
The same with
|
IMHO that makes sense. |
I'd previously spelunked the code finding commands from calling functions. Now I try out the commands and some of them don't get to the fail code path; |
I really like the new message but i am not sure about making it an error. Maybe you dont want to jump to the new index state: the current one could work and you dont want to invalidate the cache and wait 2 hours to compile dependencies. Maybe a little bit convoluted. I know you want to update your hackage index most of times but not sure if always. And make it an error will force you to make some action. What about mention the possible consequences of not updating the index? It will make the warning larger, more annyoing and users will be eager to silent it :-P |
@jneira in that case maybe we can add to the message to say that removing the |
but keeping it as an error? then this would hold, no?:
I am not assuming the requested index state is something the user has set on purpose. It could be part of a given cabal.project from a random project you just want to compile. And maybe you dont want to make changes in the repo files and/or you know nothing about the index state thing. You could do |
How about enabling the error with an extra flag (that you can stick in you cabal.project or ~/.cabal/config)? |
he, you know, there is nothing a new flag can not solve but too much extra flags 😉 |
Agreed. But if it's an unconditional change that breaks workflows and scripts, we need an RFC ticket, and if it confuses newbies, we need improved docs, improved messages and perhaps more. |
Tried that and it works. |
Ok, lets think if we can achieve the error/warning logic using the existing config options.
maybe we could add a EDIT: |
It allows put the hackage server name:
so we have to be careful about the format and the parsing, to allow hackage servers containing Create a new flag would be cleaner in that respect and it would not affect users |
Infix, the vibe I get from the current behaviour is |
OTOH, new users often never do |
An idea: we could post an RFC to Discourse, perhaps with some initial proposal of the adoption plan, e.g., block behind a flag, first the flag is off, but printed in ~/.cabal/config and advertised and |
I'm for converting the warning to an error (mentioning I don't think we need an RFC or gradual adoption or anything like that. We are allowed to make breaking changes on major versions after all. And this is cabal-install, not Cabal |
@fgaz: I'm going to tell on you to the Stability Working Group. |
well sure we are gonna break a bunch of things but next release will have so many shiny features and old bug fixes than nobody will notice :-P |
You mean, backward incompatible but working features will be the least of our worries? Quite probable, given that we have a monster release on our hands, but all the more reason to try and limit the post-release bedlam. |
I think the warning is broken though. It seems like the intention was to only issue a warning if the fallback was unsafe (out of range), but it is issued even if the index head is after |
My 2 cents as a first time user: After trying to use freeze file to make our builds reproducible, and learning it is not really easily possible to use it right now for that in the context of multiple platforms and team members, we decided to just fix the index-state via That sounded great -> practical enough for our needs and very simple. I certainly didn't expect that it will allow building with older index-state however! I thought this will ensure that exact specific index state is used. I learned about this unexpected behaviour only when @philderbeast warned me about it. And I agree that warning is not strong enough - there is so much output, I would likely never see it. I understand it would be a breaking change to make this an error, but only for users who use |
No objections from users so far and a couple have seen this despite no RFC. Do we know how many people have Trawling github produces 700 hits, but perhaps most of these are forks of one repo? |
hls uses it since long time ago and i have to admit i was bitten for this not being an error. Usually you got a solver error followed by a sigh and a |
I was relying on intuition here and that was wrong. Asking for I've found two spots in the docs where
What does
I find Questions I have
|
From this comment on stackage, it looks like the answer to question 3 is a,
|
|
BTW, I was convinced by the participants of the cabal dev's meeting on 7 Apr 2022 that the old behaviour, the not erroring out, was buggy, so if a user's script depends on it, it depends on a bug, so we are fine fixing the bug in a major version, with proper warnings in release notes. Let's remember to add the warnings, ideally in the very PR that fixes the bug. (Where could we put it, in addition to the normal changelog?) [Edit; and let's remember to describe how to easily get the old behaviour.] |
I haven't yet started on adding tests for this but am leaving this snippet here to later investigate and incorporate into a test.
|
I am very much in favour of this. I am often in the position of having to distribute Haskell software in source form to people, and neglecting to run I would even go farther and say that if index-state is present, |
Some projects set an arbitrary index state, for instance in haskell-language-server's cabal.project it is set to index-state: 2023-12-13T00:00:00Z And if you were to run it after a cabal update, you'd get the error
But I think it's okay in this case since it's just easy to set an index state at midnight in cabal.project instead of the exact timestamp. With the proposed change, will this become an error? |
why not then set |
doesn't that change the behaviour though? In the previous case we are reasonably sure it's still using the same index but now we are using the new index-state and with it likely a different build plan |
I'm confused -- is this CI or manually? (I had assumed you had script updating these or something). If manually, you can just set the actual index state without much extra work. And if you want to "round it off" for aesthetic reasons, you could round it off to the prior hour, or the prior day, or whatever you like. |
Given that this warning happens after a cabal update, I have a question. Can we get a missing index later repopulated, like we have index states at A and C, once we have C can we get B in a subsequent update? Because if not then the index-state at 2023-12-13T00:00:00Z should be the same as 2023-12-12T23:20:00Z and there is no need for a message in this scenario |
I think there is confusion. The index is chronologically ordered. The index-state just is a time which we consider the index "up to". If we have index states C, then we chronologically necessarily have all prior index states. The reason that we don't want the two above to be equivalent is that it is possible a user has not run a There was never a design consideration that people would put in a non-existent future time. |
There's actually a failure-case with the usage you describe. Suppose I set an index-state of tomorrow, and suppose everything currently builds with that, with a warning. But between now and tomorrow, now someone uploads a package to hackage which breaks things. That index-state, which worked before, no longer works. This would defeat the purpose of index-state, which is to refer to an immutable fixed set of packages. If you set a future time, then in fact you are referring to a mutable set of packages, and indeed, might as well use |
Okay that matches with my understanding, in the above example I run it after I do a
I am only referring to the situation when cabal knows the next index-state, that is in my example since I just did a cabal v2-update it knows there can be no index-states in between and that warning becomes unnecessary |
Note that recently we have merged a PR that makes cabal error out if a requested index-state is beyond the most recent index entry. |
It's #8944. @philderbeast does this satisfy your initial suggestion? |
Yes @andreabedini, from reading the expected outputs of tests, #8944 fixes this issue. Thanks @jasagredo. |
That's great to hear! |
If I have an
index-state
in the project file that is newer can we please make it an error rather than a warning whencabal build
is invoked?cabal/cabal-install/src/Distribution/Client/IndexUtils.hs
Lines 278 to 283 in ebfd8c7
We get a warning. It is on us to call
cabal update
. I'm unhappy that this is a warning and not an error as I don't think it makes sense forcabal build
to proceed. Also often there is a lot of build output and it would be easy to miss this warning.The text was updated successfully, but these errors were encountered: