commercialhaskell / commercialhaskell/stack
Compilation result may depend on the stack command order in case of mixins usage
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
### General summary/comments (optional)
If the project uses mixins to hide `Prelude` from the `base` package and custom prelude,
compilation result may depend on the `stack` command order.
### Steps to reproduce
Build the following sample stack project.
`stack.yaml`:
```
resolver: lts-16.5
packages:
- .
extra-deps:
- morley-prelude-0.3.0@sha256:9e9473ac14cfa206adf0a3700764c0251de05042f1fe45daf9cb8556079ae663,2085
```
`package.yaml`:
```
name: stack-investigation
version: 0.1.0.0
github: "githubuser/stack-investigation"
license: BSD3
author: "Author name here"
maintainer: "example@example.com"
copyright: "2020 Author name here"
extra-source-files:
- README.md
- ChangeLog.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on GitHub at
dependencies:
- name: base
version: ">= 4.7 && < 5"
mixin: [hiding (Prelude)]
library:
source-dirs: src
dependencies:
- morley-prelude
executables:
stack-investigation-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- stack-investigation
- morley-prelude
tests:
stack-investigation-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- stack-investigation
- morley-prelude
- network
```
1) Use clear `~/.stack`, `.stack-work` and run `stack test` for the current project. The build succeeds.
2) Use clear `~/.stack`, `.stack-work` and run `stack build && stack test`. The build fails with the following error:
```
network > [1 of 2] Compiling Main ( /tmp/stack-38b10cd0c119f260/network-3.1.1.1/Setup.hs, /tmp/stack-38b10cd0c119f260/network-3.1.1.1/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup/Main.o )
network >
network > /tmp/stack-38b10cd0c119f260/network-3.1.1.1/Setup.hs:1:8: error:
network > Ambiguous module name `Prelude':
network > it was found in multiple packages:
network > base-4.13.0.0 morley-prelude-0.3.0
network > |
network > 1 | module Main (main) where
network > | ^^^^
```
Looks like the problem is caused by the fact that `network` is compiled after `morley-prelude`
in the latter case, and before it in the former one.
### Expected
Both command sequences end in a successful build
### Actual
`stack build && stack test` failed with ambiguous `Prelude` error.
What actually happened.
### Stack version
2.5.0.1
### Method of installation
Linux binary from Github release.
### Archive with sample project sources
[stack-project.zip](https://github.com/commercialhaskell/stack/files/5383692/stack-project.zip)
Contributor guide
Assessment
This issue has not been assessed yet.