google / ghc-source-gen

Library for generating Haskell source files and code fragments.
BSD 3-Clause "New" or "Revised" License
89 stars 29 forks source link

Support GHC 9.8 (#108) #112

Closed mattapet closed 6 months ago

mattapet commented 6 months ago
google-cla[bot] commented 6 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

blackgnezdo commented 6 months ago

Thanks for the fixes. I'm still looking at the code, but my attempt to use stack-9.8.yaml didn't go well. I tried to run

cd ghc-source-gen && stack build --dry-run --stack-yaml ./stack-9.8.yaml build

and it fails:

Error: [S-4804]
       Stack failed to construct a build plan.

       While constructing the build plan, Stack encountered the
       following errors. The 'Stack configuration' refers to
       the set of package versions specified by the snapshot
       (after any dropped packages, or pruned GHC boot
       packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any
       extra-deps:

       In the dependencies for build-1.0:
         * algebraic-graphs must match >=0.1.1 && <0.2, but
           algebraic-graphs-0.7 is in the Stack configuration
           (latest matching version is 0.1.1.1).
         * containers must match >=0.5.7.1 && <0.6, but
           containers-0.6.8 is in the Stack configuration
           (latest matching version is 0.5.11.0).
         * extra must match >=1.5.3 && <1.7, but extra-1.7.14
           is in the Stack configuration (latest matching
           version is 1.6.21).
         * mtl must match >=2.2.1 && <2.3, but mtl-2.3.1 is in
           the Stack configuration (latest matching version is
           2.2.2).
         * random must match >=1.1 && <1.2, but random-1.2.1.1
           is in the Stack configuration (latest matching
           version is 1.1).
         * transformers must match >=0.5.2.0 && <0.6, but
           transformers-0.6.1.0 is in the Stack configuration
           (latest matching version is 0.5.6.2).

The exact configuration was created with this Dockerfile:

# Installed this first https://docs.docker.com/engine/install/debian/
# sudo docker build -t rl .
# sudo docker run --rm -it rl /bin/bash -l
FROM ubuntu:latest

RUN apt -u update && apt -y upgrade
RUN apt -y install curl

RUN curl -sSL https://get.haskellstack.org/ | sh
RUN stack upgrade
# Create a new user "myuser" (without home directory)
RUN useradd -m myuser

# Optionally set a working directory
WORKDIR /home/myuser

COPY . ghc-source-gen
RUN chown -R myuser ghc-source-gen

# Switch to the new user for subsequent actions
USER myuser
#RUN cd ghc-source-gen && stack build --dry-run --stack-yaml ./stack-9.8.yaml build
mattapet commented 6 months ago

I spent some time looking into it, but I can't seem to find where such constraints may be coming from 🤔 I also tried bumping tasty in efforts to make it work, but I was not successful.

I also tried cloning master again, and running the same Dockerfile setup with stack build --dry-run --stack-yaml ./stack-9.6.yaml build rather than 9.8, which resulted in basically the same set of errors:

Error: [S-4804]
       Stack failed to construct a build plan.

       While constructing the build plan, Stack encountered the following errors. The 'Stack configuration' refers to the set of package versions specified by the snapshot (after any dropped packages,
       or pruned GHC boot packages; if a boot package is replaced, Stack prunes all other such packages that depend on it) and any extra-deps:

       In the dependencies for build-1.0:
         * algebraic-graphs must match >=0.1.1 && <0.2, but algebraic-graphs-0.7 is in the Stack configuration (latest matching version is 0.1.1.1).
         * containers must match >=0.5.7.1 && <0.6, but containers-0.6.7 is in the Stack configuration (latest matching version is 0.5.11.0).
         * extra must match >=1.5.3 && <1.7, but extra-1.7.14 is in the Stack configuration (latest matching version is 1.6.21).
         * mtl must match >=2.2.1 && <2.3, but mtl-2.3.1 is in the Stack configuration (latest matching version is 2.2.2).
         * random must match >=1.1 && <1.2, but random-1.2.1.1 is in the Stack configuration (latest matching version is 1.1).
         * transformers must match >=0.5.2.0 && <0.6, but transformers-0.6.1.0 is in the Stack configuration (latest matching version is 0.5.6.2).
       The above is/are needed since build is a build target.

       Some different approaches to resolving some or all of this:

         * To ignore all version constraints and build anyway, in /home/myuser/.stack/config.yaml (global configuration) or /home/myuser/ghc-source-gen/stack-9.6.yaml (project-level configuration),
           set allow-newer: true.

         * To ignore certain version constraints and build anyway, also add these package names under allow-newer-deps: build.

         * Recommended action: try adding the following to your extra-deps in /home/myuser/ghc-source-gen/stack-9.6.yaml (project-level configuration):

           - algebraic-graphs-0.1.1.1@sha256:af54e89839521f04f3b4bd980112701a31c7cf0d612776f8aa65083bcd1f3090,7734
           - containers-0.5.11.0@sha256:1af9da3baaddc4f4aaea016b07d4c38ddbf702ce3f0df31120531950837996b8,17308
           - extra-1.6.21@sha256:25ace0d94971ffd70623dc6d79bd2905e8ad2e343a10ff025097af5f7aeb599d,2774
           - mtl-2.2.2@sha256:1050fb71acd9f5d67da7d992583f5bd0eb14407b9dc7acc122af1b738b706ca3,2261
           - random-1.1@sha256:7b67624fd76ddf97c206de0801dc7e888097e9d572974be9b9ea6551d76965df,1777
           - transformers-0.5.6.2@sha256:6c959d14430f4deffb99579ba019de07c3d852a2122b6f449344386c7d75ff1d,3172

I myself am not that familiar with stack, so the errors don't tell me much. Do you know what might be the best please to look for the dependency mismatches? 🙏

blackgnezdo commented 6 months ago

I confirmed the change works fine with cabal. So let's remove the stack-9.8.yaml file that we know doesn't work and submit the rest. Thanks!

mattapet commented 6 months ago

Awesome, thanks! I removed the stack-9.8.yaml. Should we also adjust the CI anyhow as it appears to be using stack

blackgnezdo commented 6 months ago

@jinwoo could you merge this?

jinwoo commented 6 months ago

Hm... All CI jobs seem to have failed after I pushed this: https://github.com/google/ghc-source-gen/actions/runs/8510280488. Can someone take a look?

mattapet commented 6 months ago

Alright, so it seems we've got two issues:

  1. easy fix -- type signature here
  2. not so easy (I guess 😅) -- missing stack-9.8.yaml. If you read the messages above, it seems there are some issues with dependencies, so we were not sure what would be the best course of action there. Do you have any recommendations?
jinwoo commented 6 months ago

@blackgnezdo Any idea? I'm not familiar with GitHub actions. Can we have it use cabal instead of stack?

develop7 commented 6 months ago

@mattapet could you try restoring stack-9.8.yaml but with resolver: nightly-2024-03-29 (late one had it nightly-2023-something)?

mattapet commented 6 months ago

PR created. I ran stack --stack-yaml ./stack-<version>yaml test --keep-going for both, 9.8, and 9.6 which both passed.