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 cannot build projects that require Alex with the LTS-7.x resolver #5242

Closed
Calvin-L opened this issue Mar 28, 2020 · 4 comments
Closed

Comments

@Calvin-L
Copy link

General summary

One of my older projects uses an ancient resolver that no longer seems to work.

Steps to reproduce

Save this as repro.sh in an empty folder:

#!/bin/bash

set -e

cat >please-install-alex.cabal <<EOF
name:    please-install-alex
version: 0.0

executable Main
  main-is:
    Main.hs
  build-depends:
    base
  build-tools:
    alex
EOF

cat >stack.yaml <<EOF
require-stack-version: "==2.1.3"
resolver: lts-7.24
packages: [.]
EOF

cat >Main.hs <<EOF
module Main (main) where

main :: IO ()
main = do
    putStrLn "hello"
EOF

stack build

Then run it:

$ bash ./repro.sh

Expected

The project should build.

Actual

alex               > configure
alex               > [1 of 2] Compiling Main             ( /private/var/folders/d4/n6djsq8x5dv0jfx84hzl0v000000gn/T/stack-6accc37869a8dddd/alex-3.1.7/Setup.lhs, /private/var/folders/d4/n6djsq8x5dv0jfx84hzl0v000000gn/T/stack-6accc37869a8dddd/alex-3.1.7/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0/setup/Main.o )
alex               > [2 of 2] Compiling StackSetupShim   ( /Users/loncaric/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /private/var/folders/d4/n6djsq8x5dv0jfx84hzl0v000000gn/T/stack-6accc37869a8dddd/alex-3.1.7/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0/setup/StackSetupShim.o )

[...]

alex               > 9 warnings generated.
alex               > Configuring alex-3.1.7...
alex               > build
alex               > Building alex-3.1.7...
alex               > Preprocessing executable 'alex' for alex-3.1.7...
alex               > setup: The program 'happy' is required but it could not be found

--  While building package alex-3.1.7 using:
      /private/var/folders/d4/n6djsq8x5dv0jfx84hzl0v000000gn/T/stack-6accc37869a8dddd/alex-3.1.7/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0/setup/setup --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.0.0 build --ghc-options ""
    Process exited with code: ExitFailure 1
Progress 1/2

I am happy to provide more verbose logs if they will be helpful.

Stack version

$ stack --version 
Version 2.1.3 x86_64
[...]

Method of installation

  • On MacOS via Homebrew
@qrilka
Copy link
Contributor

qrilka commented Mar 28, 2020

I guess you need to add happy as a dependency as well because alex doesn't list it as it's dependency.

@Calvin-L
Copy link
Author

Adding happy to the build-tools section does not fix the problem. In fact, happy won't build either: https://gist.github.com/Calvin-L/ce1e40bde893de7eaa59738c6de7c342

I should clarify that this worked fine with an older version of Stack circa 2017/2018. I will try to reproduce that successful build; there might have been something about my environment that caused it to succeed back then when it shouldn't have.

@Calvin-L
Copy link
Author

Calvin-L commented Mar 28, 2020

Sure enough, this project does build with Stack 1.1.2.

(Unrelated: to build with the older version of Stack I had to create a Setup.hs file with these contents:

import Distribution.Simple
main = defaultMain

It is possible that this is required for modern Stack as well, but the build didn't progress far enough to let me know. Obviously I also had to remove the require-stack-version line from stack.yaml.)

Calvin-L added a commit to uwplse/epics-tools that referenced this issue Apr 4, 2020
Unfortunately, the "long-term" part of "LTS" has turned out to be a
lie.  Only 3 years in, and there is now a regression that causes Stack
to fail to build Alex and Happy (commercialhaskell/stack#5242).  There
is no easy fix, so I have upgraded the Stack resolver to 12.26, which
seems to work better.  I hope that this one is supported longer.

As part of this fix, I weakened the version requirements in the Cabal
package specification.  Everything still works as far as I can tell,
but it won't hold forever: LTS-14.x and higher have problems because of
the MonadFail changes.  Therefore the version specifiers are not a
true reflection of the package requirements.
@mpilgrem
Copy link
Member

I am closing given the passage of time and that the master branch of Stack does not support LTS < 12.0.

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

3 participants