To prevent download ghc when using stack clean.#4268
To prevent download ghc when using stack clean.#4268dbaynard merged 10 commits intocommercialhaskell:masterfrom waddlaw:fix-clean
stack clean.#4268Conversation
dbaynard
left a comment
There was a problem hiding this comment.
Thanks again.
There are 2 major issues which must be resolved.
-
The check in the stack code base that there is a valid GHC is now made optional, but downstream code has not been changed to reflect this. This makes that code more fragile. I can't speak for everyone on the project, though, so I'm getting another opinion.
-
This PR duplicates certain code paths due to bugs which have been (mostly) resolved. I've pinged @mgsloan who should be able to confirm this. Most of the additions to the code here fall into this category.
| @@ -631,8 +631,8 @@ cleanCmd opts go = | |||
| -- See issues #2010 and #3468 for why "stack clean --full" is not used | |||
| -- within docker. | |||
|
|
||
| withBuildConfigExt | ||
| :: Bool | ||
| -> Bool -- ^ If perform the stack clean |
There was a problem hiding this comment.
I'm concerned by the boolean blindness, here. The following types would be helpful.
data WithDocker
= SkipDocker
| WithDocker
data IsClean
= NotClean
| IsCleanBut see my comments on whether the docker checks are still necessary.
There was a problem hiding this comment.
Agreed, making another type that's iso to Bool is usually better.
To me the naming seems too purpose specific. I think it makes sense to instead have the name correspond to the behavioral change. That, is the name should specify whether or not it requires ghc to be installed.
| withBuildConfigExt False go Nothing inner Nothing | ||
| withBuildConfigExt False False go Nothing inner Nothing | ||
|
|
||
| -- | See issue #2010 for why this exists. Currently just used for the |
| withBuildConfigExt False True go Nothing inner Nothing | ||
|
|
||
| -- | See issue #2010 for why this exists. Currently just used for the | ||
| -- specific case of "stack clean --full". |
| } | ||
|
|
||
| (mghcBin, compilerBuild, _) <- ensureCompiler sopts | ||
| (mghcBin, compilerBuild, _) <- if bcClean bconfig then pure (Nothing, CompilerBuildStandard, False) else ensureCompiler sopts |
There was a problem hiding this comment.
This change is making the presence of a compiler optional, and so the code should reflect this — yet this implementation does not.
Subsequent code uses the compilerBuild option; it is faked here, making that code more fragile. It might be better that it has type Maybe CompilerBuild here; in this way the possible absence of a compiler is reflected in the type system. This then propagates to EnvConfig which I believe will need changes.
|
@dbaynard I don't recall the details of this part of the code, so it's best just to look at what it's doing. I agree about avoiding use of |
|
@dbaynard Thank you for reviewed!
I don't know that directly related to it. But, bypassed the ghc download at least.
OK. I will try to fix it.
That makes sense. |
|
@dbaynard Are you sure about this? |
|
Ping on this, as it's becoming stale. |
|
Ah, thank you for bearing with me — I must have looked at this 3 or 4 times and didn't notice the new commits. I'll check shortly, and then it may be worth looking at the possibilities for #4390. |
dbaynard
left a comment
There was a problem hiding this comment.
OK, I'm going to try to implement an integration test, then merge.
| -- 'wantedCompilerL', which provides the version specified by the | ||
| -- build plan. | ||
| ,envConfigCompilerBuild :: !CompilerBuild | ||
| ,envConfigCompilerBuild :: !(Maybe CompilerBuild) |
There was a problem hiding this comment.
| ,envConfigCompilerBuild :: !(Maybe CompilerBuild) | |
| ,envConfigCompilerBuild :: !(Maybe !CompilerBuild) |
I think we want to force the whole thing.
|
@dbaynard thanks! |
|
I’m more than happy to help you :) I'll do that. |
|
Great! |
|
I have note about this PR - |
|
Yes — any suggestions welcome. In particular, there is #4405 which builds on it. I'll note your comment in my review. So |
|
Thanks, sounds good to me though word order is confusing a bit, I think |
|
@dbaynard it looks like #4480 uncovered problem with this PR and I'm not yet clear how to resolve it: by default |
|
I found the lack of documentation on this precise point really disappointing — I had to go digging through the code and run some tests myself in order to see what Presumably, All this information ought to be in the stack configuration — presumably if somebody has overridden the cabal version, that override would be there? In which case we can use As an aside: the integration test has a false positive, related to #4468, which I'm yet to fix. |
|
You're mostly correct in your analysis. There's only 1 thing to note: currently Cabal version is more or less fixed for an LTS (the one shipped with GHC gets used) and Veronika (from the Twitter discussion I linked above) started a fresh issue #4488 to discuss ways around that limitation of Stack. |
|
Right so if that changes our assumption about I'll comment on the relevant issues, then. I'm quite confused by the various interactions with stack and Cabal — may seek some clarifications there, too. But for now, given |
|
Somehow missed this message @dbaynard but make it maybe a bit more clear - I don't think we could change our assumptions about |
stack cleanalways download the ghc even if it already deleted.Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!