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

Compilation result may depend on the stack command order in case of mixins usage #5414

Open
rvem opened this issue Oct 15, 2020 · 0 comments

Comments

@rvem
Copy link

rvem commented Oct 15, 2020

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 <https://github.com/githubuser/stack-investigation#readme>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant