Skip to content
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

Remove special global Cabal? #3049

Closed
mgsloan opened this issue Mar 8, 2017 · 13 comments
Closed

Remove special global Cabal? #3049

mgsloan opened this issue Mar 8, 2017 · 13 comments

Comments

@mgsloan
Copy link
Contributor

mgsloan commented Mar 8, 2017

I believe that with support for the custom-setup stanza, #2866 , we're using the snapshot / extra-deps version of Cabal for building anything with a custom-setup stanza.

For everything else, we're using the globally installed version of Cabal (the one updated via stack setup --upgrade-cabal). This can be nice, as you can update your Cabal version without needing to modify your configurations. This means that you can get bugfixes / enhancements without updating your build configs.

This seems inconsistent to me, I think it might simplify things to always use the snapshot / extra-deps version of Cabal.

Edit: One tricky detail that I'm only considering now that I've typed all this up, is that in order to build Cabal and its dependencies, we'll need to use an existing version of Cabal - likely the global one. So it seems hard to get full consistency of Cabal version used. Thoughts on this? Just special case Cabal and its transitive deps?

We'd get the following benefits:

  1. Better build reproducibility
  2. Ability to use a custom Cabal - Support using a custom Cabal  #2910 - can even have it as a local package incase you need custom modifications
  3. Obviates the need for enhancing stack setup to specify a cabal version to install (Add stack setup --install-cabal VERSION in addition to stack setup --upgrade-cabal. #2386 / Add --cabal-install #2995)
  4. Would fix Cabal version mismatch errors caused by lacking a custom-setup stanza - Stack is using a different version of cabal to install extra-deps packages #2924
  5. Obviates the need for a proposed require-cabal-version field in stack.yaml - Add "require-cabal-version" and use this to enable Cabal-1.24 build plans #2479
  6. Removal of stack setup --upgrade-cabal would mean --upgrade-cabal wants write access to system ghc installation #2230 can be closed (case where it wants to write to a system ghc install)

This would add an implicit dependency on Cabal to every package. So, if Cabal or anything it depends on is installed locally, everything must be installed locally rather than in the snapshot.

@snoyberg
Copy link
Contributor

snoyberg commented Mar 8, 2017

Big 👎. Building Cabal is a long, slow process. We don't want to add that to the beginning of every new snapshot usage.

I'd be OK with this applying just to custom Setup.hs scripts perhaps. But I'm really not seeing enough benefit for simple build types.

@mgsloan
Copy link
Contributor Author

mgsloan commented Mar 8, 2017

Hmm, not sure if I buy that argument:

  1. Package sharing between snapshots will often make recompilation of Cabal unnecessary.
  2. It seems quite probable that non-trivial projects will have some transitive dependency which uses a custom build type.

It does indeed take quite a while to build, on my machine it's ~4 minutes.

To me it seems like the downsides are:

  1. Still need to have the global Cabal around for building the snapshot / local Cabal and its deps. No straightforward way to have full consistency here.
  2. It's a change in behavior.

I'd be OK with this applying just to custom Setup.hs scripts perhaps. But I'm really not seeing enough benefit for simple build types.

Yeah, I think it makes sense to use the snapshot / local Cabal for all custom Setup.hs, regardless of the presence of a custom-setup stanza. This'd address cases where your Setup.hs depends on packages that got built with the snapshot / local Cabal - #2924

@Tehnix
Copy link

Tehnix commented Sep 18, 2017

It seems me and several others have been bitten by stack using a global version of cabal instead of the one tied to the resolver (haskell/haskell-ide-engine#315 and DanielG/ghc-mod#905).

It might be that this case is so infrequent that the work needed doesn't justify "fixing" it, but it does seem counter-intuitive that the resolver would use anything else than the one in its snapshot.

@mgsloan
Copy link
Contributor Author

mgsloan commented Dec 17, 2017

I've run into another case that I think is good evidence that Cabal version should be specified by snapshots - haskell/cabal#4137 (comment) - at least for custom setup. If we mix Cabal versions, using more recent ones for simple setup, how likely is stuff to break? Seems like that'd lead to confusing inconsistencies.

It sucks that it's using my global Cabal version (2.0), it is breaking reproducibility, as I pointed out in this issue.

Maybe the answer is to default to snapshot cabal version but allow overriding this when needed. This way, things build reliably by default.

@snoyberg
Copy link
Contributor

@mgsloan I looked through that issue, but I don't understand the reproduction. Can you describe it here?

@mgsloan
Copy link
Contributor Author

mgsloan commented Dec 23, 2017

@snoyberg stack build --resolver lts-10.0 semigroupoids-5.1 with Cabal-2 installed globally

@snoyberg
Copy link
Contributor

But in that case: Cabal-2 is also specified by the resolver itself. Won't this fail regardless? I'm looking for some reproducing test case that can demonstrate that a change in behavior within Stack will fix this.

@mgsloan
Copy link
Contributor Author

mgsloan commented Dec 24, 2017

I'm guessing that the snapshot is being built with Cabal-1.24. So, if this was resolved both here and in stackage-curator, then you'd get better compilation guarantees. So, semigroupoids wouldn't have ended up in a snapshot that also has Cabal-2.0.

It is not a straightforward decision. On one hand, this means that you cannot update your Cabal and expect to get fixes. On the other hand, custom setups can depend on a particular Cabal version and may not specify correct constraints, like in this case.

I'm actually leaning towards a bit of an ugly solution, which is to use the snapshot version of Cabal for custom builds, and use the global version of Cabal for simple builds. Perhaps the best option is just to leave the choice up to the user.

@phadej
Copy link
Collaborator

phadej commented Dec 24, 2017

Note: if custom-setup isn't specified, the implicit setup-depends are used

http://cabal.readthedocs.io/en/latest/developing-packages.html#custom-setup-scripts (the section with bounds, it seems we miss a paragraph atm)

@snoyberg
Copy link
Contributor

I'm guessing that the snapshot is being built with Cabal-1.24.

That's what I'm trying to point out: LTS 10.0 does not use Cabal 1.24, it uses 2.0.1.1 https://www.stackage.org/lts-10.0/package/Cabal-2.0.1.1

@mgsloan
Copy link
Contributor Author

mgsloan commented Dec 28, 2017

Ahh, I was being a bit thick, stack build --resolver lts-10.0 semigroupoids does work - semigroupoids-5.2.1 is in the snapshot rather than semigroupoids-5.1. So, nvm!

@SpencerPark
Copy link

As referenced in matchwood/ghcjs-stack-dist#12 I was just bitten by this issue. Everything I tried to run to get a cabal version was pointing to 1.24.2.0 but the cabal version used (for setup at least) was 2.0.1.1. It seems I may have --upgrade-cabal in the past or similar because the only cabal version in /home/Spencer/.stack/programs/x86_64-linux/ghc-8.0.2/new-cabal/ was 2.0.1.1 but the packages in lts-8.11 were all assuming 1.24.2.0.

This was especially tricky when this was being used to boot the compiler as in the case of ghcjs. Could we get a warning (at the least) about the cabal version being used does not match the snapshot and possibly a nice message about how to install the cabal version from the snapshot if stack is going to use the global one? It might help debug these sorts of issues. Thanks!

@snoyberg
Copy link
Contributor

snoyberg commented Apr 1, 2019

We're not going to be making any changes to this for now. Stack master has removed the --upgrade-cabal option to avoid further confusion.

@snoyberg snoyberg closed this as completed Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants