-
Notifications
You must be signed in to change notification settings - Fork 842
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
To prevent download ghc when using stack clean
.
#4268
Conversation
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.
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. |
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.
src/Stack/Runners.hs
Outdated
|
||
withBuildConfigExt | ||
:: Bool | ||
-> Bool -- ^ If perform the stack clean |
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'm concerned by the boolean blindness, here. The following types would be helpful.
data WithDocker
= SkipDocker
| WithDocker
data IsClean
= NotClean
| IsClean
But see my comments on whether the docker checks are still necessary.
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.
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.
@@ -127,7 +129,7 @@ withBuildConfigAndLock | |||
-> (Maybe FileLock -> RIO EnvConfig ()) | |||
-> IO () | |||
withBuildConfigAndLock go inner = | |||
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 |
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.
See comment below
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". |
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.
See comment below
src/Stack/Setup.hs
Outdated
@@ -235,7 +235,7 @@ setupEnv mResolveMissingGHC = do | |||
, soptsGHCJSBootOpts = ["--clean"] | |||
} | |||
|
|||
(mghcBin, compilerBuild, _) <- ensureCompiler sopts | |||
(mghcBin, compilerBuild, _) <- if bcClean bconfig then pure (Nothing, CompilerBuildStandard, False) else ensureCompiler sopts |
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.
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. |
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.
OK, I'm going to try to implement an integration test, then merge.
@@ -535,7 +548,7 @@ data EnvConfig = EnvConfig | |||
-- ^ The actual version of the compiler to be used, as opposed to | |||
-- 'wantedCompilerL', which provides the version specified by the | |||
-- build plan. | |||
,envConfigCompilerBuild :: !CompilerBuild | |||
,envConfigCompilerBuild :: !(Maybe CompilerBuild) |
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.
,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 clean
always 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!