commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 843 forks source link

stack init doesn't use it's own cabal #3734

Closed varosi closed 5 years ago

varosi commented 6 years ago

Steps to reproduce

  1. stack init --ignore-subdirs --resolver lts-10.2 --solver

Expected

What you expected to see and happen.

Actual

Looking for .cabal or package.yaml files to use to init the project. Using cabal packages:

  • .\

Selected resolver: lts-10.2 *** Resolver lts-10.2 will need external packages: cabal-helper not found

  • ghc-mod requires >=0.8.0.0 && <0.9 doctest version 0.13.0 found
  • ghc-mod requires <0.12 && >=0.9.3 extra version 1.6.2 found
  • ghc-mod requires <1.6 && >=1.4 monad-journal version 0.8.1 found
  • ghc-mod requires >=0.4 && <0.8 optparse-applicative version 0.14.0.0 found
  • ghc-mod requires >=0.13.0.0 && <0.14 Using package flags:
  • ghc-mod: shelltest = False

Using resolver: lts-10.2 Solver requires that cabal be on your PATH Try running 'stack install cabal-install'

It's strange that it doesn't use sandboxed cabal that it has access to. I giving it a concrete resolver, too. So it should know which cabal to use. It's not good idea to install cabal outside Stack infrastructure in my opinion.

Stack version

$ stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0

Method of installation

kadoban commented 6 years ago

Thanks for the report. That does seem like a good point, we try to handle other build tools automatically, but cabal-install we don't.

I'm not sure if there's a good reason for that or if it's something that could be improved. I can't think of any reason it couldn't be done automatically offhand. The logic might not be as trivial as just using whatever one the resolver specifies though, I'm not sure if packages in a resolver are required to be buildable with the cabal-install that's also in the same resolver.

Edit: some resolvers won't even have cabal-install in them of course, though if that's the only blocker we could just bail in that case and let the user deal with it.

mgsloan commented 6 years ago

I think the reason for this is that when init is running, we haven't set up a stack environment yet. When the resolver is specified, it does make sense to me to include it on the PATH. Interesting special case!

So yeah, I'm in favor of doing this. It should be a straightforward change - PRs appreciated!

b-hass commented 5 years ago

Hello @mgsloan , I am new to the project and would like to work on this issue. Could you point me the right direction to start?

snoyberg commented 5 years ago

We've removed the solver support in #4670