-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
haskell-stack: bootstrap stack with stack #1480
Conversation
Also, see commercialhaskell/stack#2182 and commercialhaskell/stack#2192 for the prior conversations. |
CC @zmwangx |
works only because I'm 👍 on this if it provably solves a problem though. |
We (the Stack release team) very much intend to keep I'm building this PR now, so I'll let you know whether it solves the original problem. |
@borsboom If you don't mind, please also check the current bottle that's distributed in master as well since it differs from the one the user reporting the original issue was using, so we don't actually know at this point whether the current bottle is or isn't broken in the relevant sense. |
Ok, I just compared the existing bottle to the new build, and I can confirm that the existing bottle fails and the new build succeeds:
So this solves the original problem and I expect it will prevent other problems in the future. Incidentally, other Haskell-built programs may also benefit from being built by Stack rather than cabal-install if their source code includes a |
@borsboom That's with homebrew-core/Formula/haskell-stack.rb Line 15 in e5e8ca8
|
Yes, my local Formula/haskell-stack.rb has the same SHA256 for the bottle and I just installed that bottle before running my test. |
@borsboom Homebrew/legacy-homebrew#49158 for the prior conversation on whether using stack more generally might be a viable option for Homebrew. |
@borsboom In a local test, not the CI for the PR which as you can see passed, I just got this:
Do I need to deparallelize stack setup in some way? Is that a known bug? |
|
@borsboom does stack install have the same issue? |
It potentially can if parallel installs of the same package go into the same shared sandbox (in the STACK_ROOT). |
aa9b535
to
ebe03b6
Compare
@borsboom PR refreshed. I think that will fix it. |
@DomT4 I wonder if it would be wise to specify a folder within HOMEBREW_CACHE for the stack downloads to accumulate, on analogy to the java cache thingy. |
cabal_sandbox do | ||
cabal_install | ||
|
||
# Let `stack` handle its own parallelization |
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.
What happens without this? Seems weird.
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.
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.
Does it work to just have it for stack setup
and leave stack install
as normal? No worries if not, just seems odd.
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.
It's possible that the only problem was that I was explicitly setting STACK_ROOT
. I should try with just passing -j#{jobs}
but not wrapped in the ENV.deparallelize.
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.
Yeah, we may not need to pass -j#{jobs}
at all either, but it seems that's probably the "right" thing to do, as it's the same thing we do with cabal: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/language/haskell.rb#L58
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.
Note that the breakage occurred without setting -j
at all, but with setting STACK_ROOT
.
ebe03b6
to
8dc2c08
Compare
Without the wrapping in ENV.deparallelize, the error showed up again during stack setup, this time on CI.
So I've put that back in. |
8dc2c08
to
4c32736
Compare
On the one hand, I'm pleased that this bootstrapping technique works without much fuss. On the other hand, I kind of wish we knew what was causing |
It's mentioned in https://github.com/commercialhaskell/stack/blob/master/doc/docker_integration.md#configuration, if helpful at all. |
I'm also thinking this formula should be renamed |
I actually think of this bootstrapping technique fixing a general problem (that there's no guarantee that the Homebrew version of |
Sure, but this bug precedes the monkeying with |
Not sure if I'm reading it correctly, but it looks like you're only using the sdist for the |
7eed978
to
d1e44e6
Compare
@boorsboom OK, that makes sense. I did that because the patches here (and in the future) are much more likely to apply cleanly to the GitHub tag. Would it be correct to simply replace the cabal.config with the one from sdist? |
|
d1e44e6
to
4e0818c
Compare
@borsboom OK, refreshed the PR using sdist's stack.cabal. How's that looking? |
4e0818c
to
83f8da6
Compare
I guess you're just copying the |
@borsboom That's probably a good idea. My concern is just that if an important GitHub commit "foo.patch" is needed in the future between releases that someone might get confused when the commits refuse to apply cleanly, but I suppose we can cross that bridge if/when we get there. |
The idea for this commit is from Emanuel Borsboom, who has suggested that bootstrapping should help prevent Homebrew-specific regressions caused by Cabal's Solver choosing different versions of stack's dependencies as compared to the versions used when building the upstream binaries. Note that the stage 1 stack gathers its own resources including even the compiler. Regarding the security implications of this approach, see https://www.fpcomplete.com/blog/2015/07/package-security-in-stack https://www.fpcomplete.com/blog/2016/05/stack-security-gnupg-keys A non-default option to skip bootstrapping and just install the stage 1 build is included as well.
83f8da6
to
4a31dd4
Compare
@borsboom OK, updated to use sdist only. Note that the version needs to be specified manually since brew's version detector thingy is confused by the sdist url. |
LGTM! |
@borsboom Cool. BTW, I suspect this will also work out-of-the-box on Linuxbrew. |
@borsboom Is there an environment variable for specifying a cache location for the downloads? I think we might be able to accomplish something similar to the |
Those are all kept in the STACK_ROOT. |
@ilovezfs Is |
@DomT4 The current version here is downloading a ton of external resources every run... including the compiler, and then throwing it all out. |
@DomT4 Hence #1480 (comment) |
@ilovezfs I see. Sorry, didn't see the original comment, this thread got kind of busy 😄. If usage is limited to this formula I don't have an objection to an |
@DomT4 Longer-term I think we're going to want to switch from the current cabal sandbox approach to some combination of haskell stack (the current blocker to that is commercialhaskell/stack#848) and cabal new-build, but at the moment the concern is only this formula and users with slow Internet connections and/or bandwidth caps, so I'm not imagining anything for superenv at this point, just a one-off analogue for this formula alone. However, I'm not sure if there's any way to "reset" a STACK_ROOT but preserve the downloads to avoid "contamination" between builds. |
You could probably delete everything except |
@ilovezfs Cool. You're more than welcome to introduce a tweak for the single formula here as long as we avoid introducing DSL where the application is narrow, is basically what I was getting at vaguely. I'll trust you on longer-term Cabal changes, I've done my utmost to avoid getting involved in Haskell stuff heh. |
😆 😆
Wouldn't dream of it :) |
PR seems good to me 👍 |
Setting
Worth exploring further perhaps, but I don't think that needs to block this PR. |
@borsboom It has 🚢'ed if you'd like to verify it's 💯 . |
The idea for this commit is from Emanuel Borsboom, who has suggested that bootstrapping should help prevent Homebrew-specific regressions caused by Cabal's Solver choosing different versions of stack's
dependencies as compared to the versions used when building the upstream binaries.
Note that the stage 1 stack gathers its own resources including even the compiler. Regarding the security implications of this approach, see
https://www.fpcomplete.com/blog/2015/07/package-security-in-stack
https://www.fpcomplete.com/blog/2016/05/stack-security-gnupg-keys
A non-default option to skip bootstrapping and just install the stage 1 build is included as well.