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

Stack picks up the wrong compiler when using stack init --solver #1529

Closed
harendra-kumar opened this issue Dec 17, 2015 · 3 comments
Closed

Comments

@harendra-kumar
Copy link
Collaborator

stack is setup to use ghc-7.8.4 from lts-2.22

cueball:/vol/hosts/cueball/workspace/halberd$ stack exec which ghc
Run from outside a project, using implicit global project config
Using resolver: lts-2.22 from implicit global project's config file: /var/home/harendra/.stack/global-project/stack.yaml
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.8.4/bin/ghc

But cabal invoked by stack init --solver is picking up the one which is in the user path:

cueball:/vol/hosts/cueball/workspace/halberd$ stack init --solver
Writing default config file to: /vol/hosts/cueball/workspace/halberd/stack.yaml
Basing on cabal files:
- /vol/hosts/cueball/workspace/halberd/halberd.cabal

Asking cabal to calculate a build plan, please wait
Running /var/home/harendra/.local/bin/cabal --config-file=/tmp/cabal-solver6697/cabal.config install --enable-tests --enable-benchmarks -v --dry-run --only-dependencies --reorder-goals --max-backjumps=-1 --package-db=clear --package-db=global /vol/hosts/cueball/workspace/halberd/ exited with ExitFailure 1
/var/home/harendra/.stack/snapshots/x86_64-linux/lts-3.14/7.10.2/bin/cpphs --version
/usr/bin/gcc -dumpversion
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.10.2/bin/haddock --version
/var/home/harendra/.stack/snapshots/x86_64-linux/lts-3.14/7.10.2/bin/happy --version
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.10.2/bin/hpc version
looking for tool hsc2hs near compiler in
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.10.2/bin
found hsc2hs in
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.10.2/bin/hsc2hs
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.10.2/bin/hsc2hs --version
/var/home/harendra/.stack/snapshots/x86_64-linux/lts-3.14/7.10.2/bin/HsColour -version
/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.10.2/bin/ghc -c /tmp/1804289383846930886.c -o /tmp/16816927771714636915.o
/usr/bin/ld -x -r /tmp/16816927771714636915.o -o /tmp/1957747793424238335.o
/usr/bin/pkg-config --version
/bin/tar --help
Reading available packages...
Updating the index cache file...
Choosing modular solver.
Resolving dependencies...

cabal: Could not resolve dependencies:
trying: halberd-0.1.2.9 (user goal)
next goal: base (dependency of halberd-0.1.2.9)
rejecting: base-4.8.1.0/installed-4f7... (conflict: halberd => base>=4.5 &&
<4.8)
rejecting: base-4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0,
4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1,
4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global constraint requires
installed instance)
Dependency tree exhaustively searched.

We can see 7.10.2 being picked up above and solver failing because of incompatible base package. Perhaps cabal is not being called with modified environment.

@harendra-kumar
Copy link
Collaborator Author

Tried with a user path modification including the correct compiler in path and it worked as expected:

cueball:/vol/hosts/cueball/workspace/halberd$ /usr/bin/env PATH=/var/home/harendra/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/home/harendra/.stack/programs/x86_64-linux/ghc-7.8.4/bin stack init --solver
Writing default config file to: /vol/hosts/cueball/workspace/halberd/stack.yaml
Basing on cabal files:
- /vol/hosts/cueball/workspace/halberd/halberd.cabal

Asking cabal to calculate a build plan, please wait
Selected resolver: ghc-7.8.4
Wrote project config to: /vol/hosts/cueball/workspace/halberd/stack.yaml

@mgsloan
Copy link
Contributor

mgsloan commented Dec 18, 2015

Indeed, looks like the logic for stack solver first checks for a ghc on the path, and then looks for installed versions. Puzzlingly, this doesn't seem to pay attention to the resolver at all when picking ghc... Seems pretty broken! https://github.com/fpco/stack/blob/d927b4b553e1f5cbc627e68e10e88fbd318475a9/src/Stack/Solver.hs#L56

Perhaps it should use ensureCompiler, so that the logic is the same as usual. Could have the bonus of supporting stack init --install-ghc

Something else to consider is that I don't see any reason stack init --resolver lts-3.16 --solver wouldn't be a reasonable thing to do. It would use the cabal solver to pick the extra-deps outside the snapshot. However, currently you can only pick MethodResolver, MethodSolver, or MethodSnapshot.

@harendra-kumar
Copy link
Collaborator Author

In fact if you look at the examples in #1531 I tried exactly what you are suggesting i.e. stack init --resolver lts-3.16 --solver because I thought that's logical to do and might possibly be implemented. But no luck!

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

3 participants