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

Fix #5697 Move stack to lts-19.16 (GHC 9.0.2) from lts-17.15 (GHC 8.10.4) #5736

Closed
wants to merge 1 commit into from

Conversation

mpilgrem
Copy link
Member

@mpilgrem mpilgrem commented May 7, 2022

Also corrects a typo in stack-ghc-902.yaml comment.

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

Please also shortly describe how you tested your change. Bonus points for added tests! Tested by building, and using, stack.

@mpilgrem
Copy link
Member Author

mpilgrem commented May 9, 2022

I may have unestimated what is required, as I see that the various tests have stack.yaml files that refer to out of date versions of GHC. I am going to see what happens if I update them to GHC 9.0.2 also. EDIT: My initial objective is to get a version that at least passes the Windows-based tests.

@mpilgrem mpilgrem force-pushed the fix5697 branch 6 times, most recently from bbdbd37 to c239db8 Compare May 11, 2022 21:53
@mpilgrem
Copy link
Member Author

This revised pull request is now at the stage where the Windows-based tests (unit and integration) pass, but tests for other operating systems do not. I think that is because an updated 'docker' image is required, and I have raised an issue in the relevant repository.

To summarise my approach to tests, with some exceptions, I replaced references to LTS resolvers with lts-19.6, to nightly resolvers with nightly-2022-03-17 (the most recent based on GHC 9.0.2), and to compilers with ghc-9.0.2. Where needed, I also bumped references to packages to be consistent with those changes.

A test using StackTest.runRepl failed because the directory /tmp (corresponding to C:\tmp) does not exist on Windows. I don't know how it succeeded before. I varied runRepl to use the Windows TEMP directory on Windows.

For test 4488-newer-cabal-version, stack does not support cabal-version: 3.6, so I used ghc-8.6.5 and cabal-version: 3.4. This required some stack setup in the test's Main.hs.

For test 4754-rebuild-haddocks, GHC 9.0.2 tolerates invalid Haddocks. So, I added flags -Winvalid-haddock and -Werror.

For disabled test cabal-subsidiary-dependency, the CI now has GHC >= 8.8.1, so I reintroduced the test.

For test internal-libraries, I understand that an upstream bug in Cabal means that the test must be run with GHC < 9. So, some stack setup is required in the test's Main.hs.

@mpilgrem
Copy link
Member Author

In respect of the CI on Unix-like operating systems, at fpco/alpine-haskell-stack#5 (comment) a kind offer has been made to enable a GHC 9.0.2 docker image in DockerHub, if somebody can send a pull request for it. The PR should target this branch: https://github.com/fpco/alpine-haskell-stack/tree/ghc902. Also, the latest stable alpine (possibly version 3.15.4) should be used as the base image.

Can anybody reading this assist?

@mpilgrem mpilgrem changed the title Fix #5697 Move stack to lts-19.6 (GHC 9.0.2) from lts-17.15 (GHC 8.10.4) Fix #5697 Move stack to lts-19.7 (GHC 9.0.2) from lts-17.15 (GHC 8.10.4) May 19, 2022
@mpilgrem
Copy link
Member Author

The problem with the macOS integration tests, is things like this (extract):

2022-05-19T20:37:04.1854590Z Running integration test 1/108: 111-custom-snapshot
...
2022-05-19T20:37:12.1068550Z Failure, dumping log
2022-05-19T20:37:12.1069450Z 
2022-05-19T20:37:12.1069890Z 
2022-05-19T20:37:12.1070410Z Running: /Users/runner/work/stack/stack/_release/bin/stack-2.7.6-osx-x86_64/stack build
2022-05-19T20:37:12.1072480Z No compiler found, expected minor version match with ghc-9.0.2 (x86_64) (based on resolver setting in /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/stack-integration-111-custom-snapshot84196/stack.yaml).
2022-05-19T20:37:12.1074470Z To install the correct GHC into /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/home84196/.stack/programs/x86_64-osx/, try running "stack setup" or use the "--install-ghc" flag. To use your system GHC installation, run "stack config set system-ghc --global true", or use the "--system-ghc" flag.
2022-05-19T20:37:12.1075420Z Main.hs: Exited with exit code: ExitFailure 1
2022-05-19T20:37:12.1075850Z CallStack (from HasCallStack):
2022-05-19T20:37:12.1076420Z   error, called at /Users/runner/work/stack/stack/test/integration/lib/StackTest.hs:63:34 in main:StackTest
2022-05-19T20:37:12.1077430Z   stack, called at /Users/runner/work/stack/stack/test/integration/tests/111-custom-snapshot/Main.hs:4:8 in main:Main
2022-05-19T20:37:12.1077840Z 
2022-05-19T20:37:12.1077850Z 
2022-05-19T20:37:12.1078160Z End of log for 111-custom-snapshot

It is looking for GHC 9.0.2 and not finding it, including at /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/home84196/.stack/programs/x86_64-osx/.

I think this part of IntegrationSpec.runApp is relevant, which turns off install-ghc and turns on system-ghc:

app = App
  { appSimpleApp = simpleApp
  , appRunghc = runghc
  , appLibDir = libdir
  , appSetupHome = \inner' -> withSystemTempDirectory "home" $ \newHome -> do
    let newStackRoot = newHome </> ".stack"
    createDirectoryIfMissing True newStackRoot
    let modifyEnv'
      = Map.insert "HOME" (fromString newHome)
      . Map.insert "APPDATA" (fromString newHome)
      . Map.insert "STACK_ROOT" (fromString newStackRoot)
      writeFileBinary (newStackRoot </> "config.yaml") "system-ghc: true\ninstall-ghc: false\n"
      withModifyEnvVars modifyEnv' inner'
  , appTestDirs = testDirs
  }

What I can't currently identify is: where in the .github/workflows/integration-tests.yml does the 'system GHC' get installed? And why is this a problem for macos-latest but not windows-latest?

@mpilgrem
Copy link
Member Author

mpilgrem commented May 21, 2022

Where might it be looking for the 'system GHC'? There is also this in the log (extract, edited). /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin is listed twice on the PATH. If stack had downloaded GHC 9.0.2, that is where I would have expected it to be located:

2022-05-19T20:37:04.1736460Z Running with the following environment
2022-05-19T20:37:04.1850410Z PATH=
/Users/runner/work/stack/stack/.stack-work/install/x86_64-osx/c21b03e833d0f8566cef88c397ff86d1a1a5567592b3c036d828f6b947f69917/9.0.2/bin
:/Users/runner/.stack/snapshots/x86_64-osx/c21b03e833d0f8566cef88c397ff86d1a1a5567592b3c036d828f6b947f69917/9.0.2/bin
:/Users/runner/.stack/compiler-tools/x86_64-osx/ghc-9.0.2/bin
:/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin
:/Users/runner/.stack/.stack-work/install/x86_64-osx/2c8263ac1a4099533510145f928c08a1d3efea9eeba0f5f3ae1c0e3d06594b6d/9.0.2/bin
:/Users/runner/.stack/snapshots/x86_64-osx/2c8263ac1a4099533510145f928c08a1d3efea9eeba0f5f3ae1c0e3d06594b6d/9.0.2/bin
:/Users/runner/.stack/compiler-tools/x86_64-osx/ghc-9.0.2/bin
:/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin
:/usr/local/lib/ruby/gems/2.7.0/bin
:/usr/local/opt/[email protected]/bin
:/usr/local/opt/pipx_bin
:/Users/runner/.cargo/bin
:/usr/local/opt/curl/bin
:/usr/local/bin
:/usr/local/sbin
:/Users/runner/bin
:/Users/runner/.yarn/bin
:/Users/runner/Library/Android/sdk/tools
:/Users/runner/Library/Android/sdk/platform-tools
:/Users/runner/Library/Android/sdk/ndk-bundle
:/Library/Frameworks/Mono.framework/Versions/Current/Commands
:/usr/bin:/bin:/usr/sbin
:/sbin
:/Users/runner/.dotnet/tools
:/Users/runner/.ghcup/bin
:/Users/runner/hostedtoolcache/stack/2.7.5/x64

@mpilgrem
Copy link
Member Author

I've added something to integration-tests.yml to reveal all ghc in the stack environment (which itself triggers the download of GHC 9.0.2 to the usual place). I think the original problem may be something to do with this: macos-latest and ubuntu-latest come with GHCup 0.1.17.8 and .ghcup/bin/ghc, while windows-latest does not. I think, somehow, that means that stack etc/scripts/release.hs check was not triggering stack to download GHC 9.0.2 into the usual place before the tests were run.

@mpilgrem
Copy link
Member Author

The macOS integration tests are still failing (in the same way), despite the fact that GHC 9.0.2 should be on the PATH:

2022-05-21T19:39:08.7565890Z Installing GHC ...
2022-05-21T19:39:23.2448460Z Installed GHC.
2022-05-21T19:39:26.4418450Z /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc
2022-05-21T19:39:26.4418780Z /Users/runner/.ghcup/bin/ghc

@mpilgrem
Copy link
Member Author

mpilgrem commented May 22, 2022

I am going to temporarily modify 111-custom-snapshot/Main.hs to see if that helps diagnose the macos-latest CI problem, to:

import StackTest

main :: IO ()
main = do
  stack ["--verbose", "build"]

Now, we have this information below (extracts only). It looks like the compiler is found at /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 but rejected as 'invalid' with error message: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-pkg-9.0.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device). The same error is given for the .ghcup compilers.

I don't know if it is relevant but: GHC 9.0.2 ships with process-1.6.13.2 and process-1.6.14.0 contains a fix related to posix-spawnp on 'Darwin' (on which macOS is based).

2022-05-22T18:31:35.1448980Z Running integration test 1/108: 111-custom-snapshot
...
2022-05-22T18:31:41.2586160Z Failure, dumping log
2022-05-22T18:31:41.2586380Z 
2022-05-22T18:31:41.2586390Z 
2022-05-22T18:31:41.2590000Z Running: /Users/runner/work/stack/stack/_release/bin/stack-2.7.6-osx-x86_64/stack --verbose build
...
2022-05-22T18:31:41.2618510Z 2022-05-22 18:31:38.136687: [debug] Asking for a supported GHC version
2022-05-22T18:31:41.2618910Z 2022-05-22 18:31:38.136749: [debug] Getting system compiler version
2022-05-22T18:31:41.2619870Z 2022-05-22 18:31:38.137844: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2"]
...
2022-05-22T18:31:41.2623590Z 2022-05-22 18:31:38.138627: [debug] Run process: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
2022-05-22T18:31:41.2624160Z 2022-05-22 18:31:38.273631: [debug] Process finished in 134928311000ms: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
...
2022-05-22T18:31:41.2626100Z 2022-05-22 18:31:38.276061: [debug] Not using compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": Found an invalid compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-pkg-9.0.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device)
2022-05-22T18:31:41.2627340Z 2022-05-22 18:31:38.277639: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2"]
...
2022-05-22T18:31:41.2631230Z 2022-05-22 18:31:38.278279: [debug] Run process: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
2022-05-22T18:31:41.2631800Z 2022-05-22 18:31:38.381311: [debug] Process finished in 102966314000ms: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
...
2022-05-22T18:31:41.2633500Z 2022-05-22 18:31:38.383390: [debug] Not using compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": Found an invalid compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-pkg-9.0.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device)
2022-05-22T18:31:41.2634700Z 2022-05-22 18:31:38.390401: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/Users/runner/.ghcup/ghc/9.0.2/bin/ghc-9.0.2"]
...
2022-05-22T18:31:41.2638360Z 2022-05-22 18:31:38.391128: [debug] Run process: /Users/runner/.ghcup/ghc/9.0.2/bin/ghc-9.0.2 --info
2022-05-22T18:31:41.2638880Z 2022-05-22 18:31:40.633920: [debug] Process finished in 2242870786000ms: /Users/runner/.ghcup/ghc/9.0.2/bin/ghc-9.0.2 --info
...
2022-05-22T18:31:41.2640410Z 2022-05-22 18:31:40.635983: [debug] Not using compiler at "/Users/runner/.ghcup/ghc/9.0.2/bin/ghc-9.0.2": Found an invalid compiler at "/Users/runner/.ghcup/ghc/9.0.2/bin/ghc-9.0.2": /Users/runner/.ghcup/ghc/9.0.2/bin/ghc-pkg-9.0.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device)
2022-05-22T18:31:41.2641600Z 2022-05-22 18:31:40.637362: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2"]
...
2022-05-22T18:31:41.2645470Z 2022-05-22 18:31:40.637960: [debug] Run process: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
2022-05-22T18:31:41.2646040Z 2022-05-22 18:31:40.736979: [debug] Process finished in 98955465000ms: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
...
2022-05-22T18:31:41.2647740Z 2022-05-22 18:31:40.738976: [debug] Not using compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": Found an invalid compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-pkg-9.0.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device)
2022-05-22T18:31:41.2648970Z 2022-05-22 18:31:40.740150: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2"]
...
2022-05-22T18:31:41.2652720Z 2022-05-22 18:31:40.740710: [debug] Run process: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
2022-05-22T18:31:41.2653280Z 2022-05-22 18:31:40.863758: [debug] Process finished in 122987372000ms: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 --info
...
2022-05-22T18:31:41.2654980Z 2022-05-22 18:31:40.865801: [debug] Not using compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": Found an invalid compiler at "/Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2": /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-pkg-9.0.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device)
2022-05-22T18:31:41.2656160Z 2022-05-22 18:31:40.870014: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/Users/runner/.ghcup/ghc/9.2.2/bin/ghc-9.2.2"]
...
2022-05-22T18:31:41.2659340Z 2022-05-22 18:31:40.873150: [debug] Run process: /Users/runner/.ghcup/ghc/9.2.2/bin/ghc-9.2.2 --info
2022-05-22T18:31:41.2659850Z 2022-05-22 18:31:41.127919: [debug] Process finished in 254709086000ms: /Users/runner/.ghcup/ghc/9.2.2/bin/ghc-9.2.2 --info
...
2022-05-22T18:31:41.2661360Z 2022-05-22 18:31:41.129937: [debug] Not using compiler at "/Users/runner/.ghcup/ghc/9.2.2/bin/ghc-9.2.2": Found an invalid compiler at "/Users/runner/.ghcup/ghc/9.2.2/bin/ghc-9.2.2": /Users/runner/.ghcup/ghc/9.2.2/bin/ghc-pkg-9.2.2: startProcess: posix_spawnp: illegal operation (Inappropriate ioctl for device)
2022-05-22T18:31:41.2661970Z 2022-05-22 18:31:41.130285: [debug] Installed tools: 
2022-05-22T18:31:41.2662200Z  - 
2022-05-22T18:31:41.2662540Z 2022-05-22 18:31:41.130339: [debug] Potential GHC builds: standard
2022-05-22T18:31:41.2662960Z 2022-05-22 18:31:41.130400: [debug] Found already installed GHC builds: 
2022-05-22T18:31:41.2663710Z 2022-05-22 18:31:41.130885: [error] No compiler found, expected minor version match with ghc-9.0.2 (x86_64) (based on resolver setting in /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/stack-integration-111-custom-snapshot24615/stack.yaml).
2022-05-22T18:31:41.2664740Z To install the correct GHC into /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/home24615/.stack/programs/x86_64-osx/, try running "stack setup" or use the "--install-ghc" flag. To use your system GHC installation, run "stack config set system-ghc --global true", or use the "--system-ghc" flag.
2022-05-22T18:31:41.2665540Z Main.hs: Exited with exit code: ExitFailure 1
2022-05-22T18:31:41.2665780Z CallStack (from HasCallStack):
2022-05-22T18:31:41.2666090Z   error, called at /Users/runner/work/stack/stack/test/integration/lib/StackTest.hs:63:34 in main:StackTest
2022-05-22T18:31:41.2666690Z   stack, called at /Users/runner/work/stack/stack/test/integration/tests/111-custom-snapshot/Main.hs:5:3 in main:Main
2022-05-22T18:31:41.2666920Z 
2022-05-22T18:31:41.2666920Z 
2022-05-22T18:31:41.2667110Z End of log for 111-custom-snapshot

@mpilgrem
Copy link
Member Author

If I build stack with process-1.6.14.0 (locally, on macOS 10.15.5), I get the same problem but with a different error message: ... ghc-pkg-9.0.2: startProcess: posix_spawnp: invalid argument (Bad file descriptor), this follows Run process: /Users/ ... /.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-pkg-9.0.2 --global -no-user-package-db dump --expand-pkgroot.

@mpilgrem
Copy link
Member Author

The error is flowing from this line in Stack.Setup.pathsFromCompiler:

globalDump <- withProcessContext menv $ globalsFromDump pkg

which leads, via Stack.SourceMap.globalsFromDump and Stack.PackageDump.ghcPkgDump and Stack.PackageDump.ghcPkgCmdArgs to Stack.Prelude.sinkProcessStdout.

@mpilgrem
Copy link
Member Author

mpilgrem commented May 27, 2022

Stack.Prelude.sinkProcessStdout includes the comment: 'Should not be used for long-running processes or ones with lots of output; for that use sinkProcessStderrStdout'. So, I am going to try substituting that function into Stack.PackageDump.ghcPkgCmdArgs. ...

That fixed the specific problem on macOS-latest but has revealed a later problem on macOS-latest for 111-snapshot-custom (and other tests), as below, [error] /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2: startProcess: dup2: invalid argument (Bad file descriptor):

2022-05-28T01:39:38.6458560Z 2022-05-28 01:39:38.375487: [debug] Constructing the build plan
2022-05-28T01:39:38.6458970Z 2022-05-28 01:39:38.375929: [debug] Parsing cabal file for mtl (from Hackage)
2022-05-28T01:39:38.6459850Z 2022-05-28 01:39:38.376201: [debug] Got blob from Pantry database for mtl-2.2.1@sha256:4b5a800fe9edf168fc7ae48c7a3fc2aab6b418ac15be2f1dad43c0f48a494a3b,1749
2022-05-28T01:39:38.6460640Z 2022-05-28 01:39:38.388511: [debug] Checking if we are going to build multiple executables with the same name
2022-05-28T01:39:38.6461110Z 2022-05-28 01:39:38.388653: [debug] Executing the build plan
2022-05-28T01:39:38.6462840Z 2022-05-28 01:39:38.391445: [debug] Run process within /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/stack-c8254fa8cbb4d999/: /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.4.1.0 /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/home72065/.stack/setup-exe-src/setup-mPHDZzAJ.hs /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/home72065/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/home72065/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2
2022-05-28T01:39:38.6464080Z 2022-05-28 01:39:38.392586: [error] /Users/runner/.stack/programs/x86_64-osx/ghc-9.0.2/bin/ghc-9.0.2: startProcess: dup2: invalid argument (Bad file descriptor)
2022-05-28T01:39:38.6464450Z Main.hs: Exited with exit code: ExitFailure 1
2022-05-28T01:39:38.6464680Z CallStack (from HasCallStack):
2022-05-28T01:39:38.6464990Z   error, called at /Users/runner/work/stack/stack/test/integration/lib/StackTest.hs:63:34 in main:StackTest
2022-05-28T01:39:38.6465560Z   stack, called at /Users/runner/work/stack/stack/test/integration/tests/111-custom-snapshot/Main.hs:5:3 in main:Main

The command that is falling over is (edited):

ghc-9.0.2 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages
  -package base
  -main-is StackSetupShim.mainOverride
  -package Cabal-3.4.1.0
  <temp_home>/.stack/setup-exe-src/setup-mPHDZzAJ.hs 
  <temp_home>/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs
  -o <temp_home>/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2

which I think is being called in Stack.Build.Execute.getSetupExe.

@psibi
Copy link
Member

psibi commented Jun 8, 2022

I just saw this PR, I have been working on similar one but for GHC 9.2.2. I will see if I can merge your changes to my branch.

@mpilgrem
Copy link
Member Author

mpilgrem commented Jun 8, 2022

As GHC 9.2.2 is said to be broken for some Windows users, I was waiting for GHC 9.2.3 to reach a Stackage resolver, and then to see if that version of GHC worked for all the important operating systems. EDIT: I see that nightly-2022-06-08 is based on GHC 9.2.3.

@mpilgrem
Copy link
Member Author

mpilgrem commented Jun 8, 2022

@psibi, my sticking point on this pull request is getting the non-Windows CI to work. In the case of macOS, my current hypothesis is that there is an upstream issue with the process library - and I have posted an issue in its repository.

@psibi
Copy link
Member

psibi commented Jun 9, 2022

Ah, I see. My plan is to get GHC 9.2.2 working and then move to GHC 9.2.3. I'm hoping that the it wouldn't be a huge change to migrate to 9.2.3.

I see that nightly-2022-06-08 is based on GHC 9.2.3.

Yeah, it seems to have appeared from today. If not, I would have started my work based out of GHC 9.2.3.

my sticking point on this pull request is getting the non-Windows CI to work. In the case of macOS, my current hypothesis is that there is an upstream issue with the process library - and I have posted an issue in its repository.

I just read your issue. That looks tricky and this migration seems more challenging that I estimated.

@psibi
Copy link
Member

psibi commented Jun 10, 2022

@mpilgrem I have been working on directly adding support for GHC 9.2.3 now. Can you see why some integration tests fail for the windows environment: https://github.com/commercialhaskell/stack/runs/6832464770?check_suite_focus=true ?

It seems it's for these three tests:

Failed tests:
- internal-libraries - ExitFailure 1
- module-added-multiple-times - ExitFailure 1
- override-compiler - ExitFailure 1

I will debug the MacOS failure on Monday further. I have the integration tests passing fine for Linux (atleast for GHC 9.2.2) and I have to just build a new Docker image to get that fixed. So in summary I think these are the things that are blocking for the new release:

  • Debug MacOS issue
  • Investigate the three integration test failures for Windows.

@mpilgrem
Copy link
Member Author

@psibi, on the three integration tests failing under Windows:

internal-libraries - see my added comment in test/integration/tests/internal-libraries/files/stack.yaml. I understand this to be an upstream issue with the Cabal library, affecting GHC 9.0 and 9.2. In the test, I used resolver ghc-8.10.7 and included a stack ["setup"] in the Main.hs.

module-added-multiple-times - I diagnosed this as a bug in test/integration/lib/StackTest.hs at about line 122. withFile "/tmp/stderr" WriteMode is referring to a directory that does not exist on Windows - I do not know why the code worked pre-GHC 9.0. I replaced the line with:

tempDir <- if isWindows
                then fromMaybe "" <$> lookupEnv "TEMP"
                else return "/tmp"
let tempFP = tempDir ++ "/stderr"

_ <- forkIO $ withFile tempFP WriteMode

override-compiler - Did you update the logic in line 7 of test/integration/tests/override-compiler/Main.hs? For GHC 9.2.3, it should read as unless (concat (lines ver) == "9.2.3") $ error $ "Invalid version: " ++ show ver.

@psibi
Copy link
Member

psibi commented Jun 11, 2022

@mpilgrem Thanks for the various hints, I will try to apply them on Monday.

Did you update the logic in line 7 of test/integration/tests/override-compiler/Main.hs? For GHC 9.2.3, it should read as unless (concat (lines ver) == "9.2.3") $ error $ "Invalid version: " ++ show ver.

Yeah, I think did because I have the integration test suite passing for Linux GHC 9.2.2.

Alsp, possibly do you think you can send the windows fixes (suggested above) to my branch (unless you want me to take your specifc fixes here, but I think it will lose your commit information) ? I think there is a quite a overlap in both of our PR, sorry for not collaborating with you earlier. I saw your PR after I started working on GHC 9.2.2 support.

Proving the above window fixes work, I think there is only one remaning unresolved thing - to figure out the MacOS integration test suite failure. I'm planning into look into it on coming Monday, but since I don't have access to a Mac machine, it might be challenging for me.

@psibi
Copy link
Member

psibi commented Jun 11, 2022

Yeah, I think did because I have the integration test suite passing for Linux GHC 9.2.2.

I was wrong. I just did the update for GHC 9.2.2 and not for 9.2.3. I guess fixing that should be trivial then. Thanks!

@mpilgrem mpilgrem marked this pull request as draft June 14, 2022 22:57
@mpilgrem mpilgrem marked this pull request as ready for review June 14, 2022 23:02
…s-17.15 (GHC 8.10.4)

Also seeks to update the tests to use a current stable release GHC compiler.

`Stack.Test.runRepl` was not working, apparently because it was referring to a directory (`/tmp`, equivalent to `C:\tmp`) that did not exist.

Uses `Stack.Prelude.sinkProcessStderrStdout` in `Stack.PackageDump.ghcPkgCmdArgs` in attempt to avoid `ghc-pkg-9.0.2: startProcess: posix_spawnp: invalid argument (Bad file descriptor)` on macOS.

Also updates the scripts to `lts-19.7`. These have been tested with `stack script <script.hs> --no-run --compile --resolver=lts-19.7`.

Adds `*.exe` to `.gitignore` (an artefact on Windows of testing scripts).

Temporarily alter CI script to try and diagnose the macOS CI problem.

Temporarily alter `111-custom-snapshot/Main.hs` to provide more information, to try and diagnose the macOS CI problem.

Temporarily depend on fork of process to try and resolve the macOS CI problem.
@mpilgrem mpilgrem changed the title Fix #5697 Move stack to lts-19.7 (GHC 9.0.2) from lts-17.15 (GHC 8.10.4) Fix #5697 Move stack to lts-19.16 (GHC 9.0.2) from lts-17.15 (GHC 8.10.4) Jul 25, 2022
@mpilgrem
Copy link
Member Author

Closing, as overtaken by #5763 (move Stack to GHC 9.2.4).

@mpilgrem mpilgrem closed this Aug 13, 2022
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

Successfully merging this pull request may close these issues.

2 participants