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 fails with Cabal-3.11.0.0 (GHC >= 9.10) #6540

Open
mpilgrem opened this issue Mar 30, 2024 · 6 comments
Open

Stack fails with Cabal-3.11.0.0 (GHC >= 9.10) #6540

mpilgrem opened this issue Mar 30, 2024 · 6 comments

Comments

@mpilgrem
Copy link
Member

GHC 9.10.0.20240328 is available (Alpha 2, first alpha for Windows). However stack build with:

snapshot: nightly-2024-03-30
compiler: ghc-9.10.0.20240328 # Override the compiler version in the snapshot

# Not needed once Stack has setup GHC 9.10.0.20240328:
setup-info:
  ghc:
    windows64:
      9.10.0.20240328:
        url: https://downloads.haskell.org/ghc/9.10.1-alpha2/ghc-9.10.0.20240328-x86_64-unknown-mingw32.tar.xz
        # Can be extended with SHA protections etc: see https://docs.haskellstack.org/en/stable/yaml_configuration/#setup-info

fails with (extract, reformatted for clarity):

Warning: Stack has not been tested with GHC versions 9.10 and above, and using 9.10.0.20240328,
         this may fail.
Warning: Stack has not been tested with Cabal versions 3.12 and above, but version 3.11.0.0 was
         found, this may fail.
...
[2 of 3] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-9p6GVs8J.hs, C:\sr\setup-exe-src\setup-shim-9p6GVs8J.o )

C:\sr\setup-exe-src\setup-shim-9p6GVs8J.hs:38:28: error: [GHC-88464]
    Variable not in scope:
      initialBuildSteps
        :: FilePath
           -> PackageDescription
           -> LocalBuildInfo
           -> Distribution.Verbosity.Verbosity
           -> IO ()
   |
38 |             | null rest -> initialBuildSteps distPref pkg_descr lbi verbosity
   |                            ^^^^^^^^^^^^^^^^^

Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error) using:
       ...\x86_64-windows\ghc-9.10.0.20240328\bin\ghc-9.10.0.20240328.exe 
       -rtsopts 
       -threaded 
       -clear-package-db 
       -global-package-db 
       -hide-all-packages 
       -package base 
       -main-is StackSetupShim.mainOverride 
       -package Cabal-3.11.0.0 
       C:\sr\setup-exe-src\setup-9p6GVs8J.hs
       C:\sr\setup-exe-src\setup-shim-9p6GVs8J.hs 
       -o C:\sr\setup-exe-cache\x86_64-windows\tmp-Cabal-simple_9p6GVs8J_3.11.0.0_ghc-9.10.0.20240328.exe
       Process exited with code: ExitFailure 1
@mpilgrem
Copy link
Member Author

mpilgrem commented Mar 30, 2024

Haddocks for Cabal-3.11.0.0: https://ghc.gitlab.haskell.org/ghc/doc/libraries/Cabal-3.11.0.0-inplace/index.html

initialBuildSteps was:

-- | Runs 'componentInitialBuildSteps' on every configured component.
initialBuildSteps :: FilePath -- ^"dist" prefix
                  -> PackageDescription  -- ^mostly information from the .cabal file
                  -> LocalBuildInfo -- ^Configuration information
                  -> Verbosity -- ^The verbosity to use
                  -> IO ()
initialBuildSteps distPref pkg_descr lbi verbosity =
    withAllComponentsInBuildOrder pkg_descr lbi $ \_comp clbi ->
        componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity

@mpilgrem
Copy link
Member Author

mpilgrem commented Mar 30, 2024

The history:

What Stack is doing is this: before using ghc --interactive, it uses replHook (with initialBuildSteps) as a way of getting Cabal to create the autogenerated files for every configured component. To use initialBuildSteps, Stack needs access to (a) the 'dist' prefix (FilePath) (b) PackageDescription (c) LocalBuildInfo (d) Vebosity - replHook is one way to get that information (some of it - the 'dist' prefix, verbosity - is provided via the ReplFlags value).

Stack introduced this to cause Cabal to create the autogenerated files for every configured component, without building everything else, making stack ghci or stack repl more efficient.

@mpilgrem
Copy link
Member Author

Related question: haskellfoundation/tech-proposals#60 (comment)

mpilgrem added a commit that referenced this issue Mar 31, 2024
Re #6540 Temporarily work around Cabal-3.11.0.0 in StackSetupShim.hs
@hasufell
Copy link
Contributor

It is confusing and depressing that Cabal invests little to no energy to understand whether they're breaking other main downstream users.

Did you open an issue at Cabal?

@mpilgrem
Copy link
Member Author

@hasufell, the corresponding Cabal issue is haskell/cabal#9856.

@mpilgrem
Copy link
Member Author

There is now a temporary workaround in Stack's master branch, as Cabal-3.11.0.0 exports what is needed for Stack to recreate the missing initialBuildSteps.

mpilgrem added a commit that referenced this issue Apr 27, 2024
Also accommodates Cabal >= 1.24 and < 2.2 (unlike the current master branch version of Stack).
TravisCardwell added a commit to TravisCardwell/haskell-actions-setup that referenced this issue May 20, 2024
Stack 2.15.7 is required to use GHC 9.10.1, as detailed in the following
issues:

* commercialhaskell/stack#6540
* haskell/cabal#9856
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

2 participants