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

Latest 9.10.1 docker images cabal that doesn't support ghc version #140

Open
CharlesEkkel opened this issue Sep 26, 2024 · 5 comments
Open

Comments

@CharlesEkkel
Copy link

As per title, the latest images install a version of cabal which doesn't support 9.10.1.

Cabal 3.10.3.0 does not support anything beyond 9.10:

 > [5/6] RUN cabal build:
0.377 'ghc' version < 9.10): /opt/ghc/9.10.1/bin/ghc is version 9.10.1
3.193 Resolving dependencies...
3.801 Error: cabal: Could not resolve dependencies:
@jhrcek
Copy link
Collaborator

jhrcek commented Sep 27, 2024

Can you please share more details about how you're encountering this error?
What command are you using to build your project? What version constraints does your project have?
Do you specify different ghc version than what's present in the image?
Aren't you maybe missing a call to cabal update to fetch latest dependencies from hackage before running cabal build?

@jhrcek
Copy link
Collaborator

jhrcek commented Sep 27, 2024

I tried locally and I got the same warning as you. But it's just a warning. It shouldn't prevent cabal from building projects with more recent ghc version.

$ docker pull haskell:9.10.1-slim-bullseye
$ docker run --rm -it haskell:9.10.1-slim-bullseye /bin/bash
# cabal init --non-interactive test-hello
# cd test-hello
# cabal build
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.10.3.0 supports
'ghc' version < 9.10): /opt/ghc/9.10.1/bin/ghc is version 9.10.1
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Build profile: -w ghc-9.10.1 -O1
In order, the following will be built (use -v for more details):
 - hello-test-0.1.0.0 (exe:hello-test) (first run)
Configuring executable 'hello-test' for hello-test-0.1.0.0..
Preprocessing executable 'hello-test' for hello-test-0.1.0.0..
Building executable 'hello-test' for hello-test-0.1.0.0..
[1 of 1] Compiling Main             ( app/Main.hs, /hello-test/dist-newstyle/build/x86_64-linux/ghc-9.10.1/hello-test-0.1.0.0/x/hello-test/build/hello-test/hello-test-tmp/Main.o )
[2 of 2] Linking /hello-test/dist-newstyle/build/x86_64-linux/ghc-9.10.1/hello-test-0.1.0.0/x/hello-test/build/hello-test/hello-test
# cabal run
Hello, Haskell!

But I would agree that we should eventually update to more recent version of cabal.
I just didn't do it yet, because at this point 3.10.3.0 is still the version recommended by ghcup.

@CharlesEkkel
Copy link
Author

CharlesEkkel commented Sep 27, 2024

Hey @jhrcek, big thanks for the detailed & prompt reply, sorry for not giving a lot of information in my initial description. I've now created a barebones project using cabal init with the following hs-docker-image-example.cabal and Dockerfile files respectively:

cabal-version:      3.4
name:               hs-docker-image-example
version:            0.1.0.0
-- synopsis:
-- description:
license:            BSD-3-Clause
license-file:       LICENSE
-- copyright:
category:           Web
build-type:         Simple
extra-doc-files:    CHANGELOG.md
-- extra-source-files:

common warnings
    ghc-options: -Wall

executable hs-docker-image-example
    import:           warnings
    main-is:          Main.hs
    -- other-modules:
    -- other-extensions:
    build-depends:    base ^>=4.20.0.0
    hs-source-dirs:   app
    default-language: GHC2024
# syntax=docker/dockerfile:1
FROM haskell:9.10.1-bullseye AS build-stage
WORKDIR /opt/hs-docker-image-example

COPY ./hs-docker-image-example.cabal /opt/hs-docker-image-example/hs-docker-image-example.cabal
RUN cabal update && cabal build  --only-dependencies -j

# Now build the app
COPY . /opt/hs-docker-image-example
RUN cabal build && \
    cp "$(cabal list-bin hs-docker-image-example)" .

CMD ["./hs-docker-image-example"]

When I run sudo docker buildx build --progress plain ., this is what I see:

[I] ~/p/h/hs-docker-image-example ❯❯❯ sudo docker buildx build --progress plain .
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 468B done
#1 DONE 0.0s

#2 resolve image config for docker-image://docker.io/docker/dockerfile:1
#2 DONE 0.8s

#3 docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5
#3 CACHED

#4 [internal] load metadata for docker.io/library/haskell:9.10.1-bullseye
#4 DONE 0.0s

#5 [ 1/14] FROM docker.io/library/haskell:9.10.1-bullseye
#5 CACHED

#6 [internal] load .dockerignore
#6 transferring context: 2B done
#6 DONE 0.0s

#7 [internal] load build context
#7 transferring context: 1.15kB done
#7 DONE 0.0s

#8 [2/6] WORKDIR /opt/hs-docker-image-example
#8 CACHED

#9 [3/6] COPY ./hs-docker-image-example.cabal /opt/hs-docker-image-example/hs-docker-image-example.cabal
#9 CACHED

#10 [4/6] RUN cabal update && cabal build --only-dependencies -j
#10 0.204 Config file path source is default config file.
#10 0.204 Config file not found: /root/.config/cabal/config
#10 0.205 Writing default configuration to /root/.config/cabal/config
#10 1.108 Downloading the latest package list from hackage.haskell.org
#10 39.69 Package list of hackage.haskell.org has been updated.
#10 39.69 The index-state is set to 2024-09-27T04:07:36Z.
#10 39.80 Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.10.3.0 supports
#10 39.80 'ghc' version < 9.10): /opt/ghc/9.10.1/bin/ghc is version 9.10.1
#10 41.53 Resolving dependencies...
#10 41.97 Error: cabal: Could not resolve dependencies:
#10 41.97 [__0] next goal: hs-docker-image-example (user goal)
#10 41.97 [__0] rejecting: hs-docker-image-example-0.1.0.0 (conflict: requires unknown
#10 41.97 language GHC2024; did you mean GHC2021?)
#10 41.97 [__0] fail (backjumping, conflict set: hs-docker-image-example)
#10 41.97 After searching the rest of the dependency tree exhaustively, these were the
#10 41.97 goals I've had most trouble fulfilling: hs-docker-image-example
#10 41.97 
#10 ERROR: process "/bin/sh -c cabal update && cabal build --only-dependencies -j" did not complete successfully: exit code: 1
------
 > [4/6] RUN cabal update && cabal build --only-dependencies -j:
39.80 'ghc' version < 9.10): /opt/ghc/9.10.1/bin/ghc is version 9.10.1
41.53 Resolving dependencies...
41.97 Error: cabal: Could not resolve dependencies:
41.97 [__0] next goal: hs-docker-image-example (user goal)
41.97 [__0] rejecting: hs-docker-image-example-0.1.0.0 (conflict: requires unknown
41.97 language GHC2024; did you mean GHC2021?)
41.97 [__0] fail (backjumping, conflict set: hs-docker-image-example)
41.97 After searching the rest of the dependency tree exhaustively, these were the
41.97 goals I've had most trouble fulfilling: hs-docker-image-example
41.97 
------
Dockerfile:6
--------------------
   4 |     
   5 |     COPY ./hs-docker-image-example.cabal /opt/hs-docker-image-example/hs-docker-image-example.cabal
   6 | >>> RUN cabal update && cabal build --only-dependencies -j
   7 |     
   8 |     # Now build the app
--------------------
ERROR: failed to solve: process "/bin/sh -c cabal update && cabal build --only-dependencies -j" did not complete successfully: exit code: 1

The build seems to fail due to not recognising GHC2024, which was introduced in ghc 9.10.1. When I just manually install ghcup and the latest versions of cabal and ghc in a more custom Dockerfile, it works successfully - so I believe this is just a matter of cabal 3.10.3.0 not supporting the new default language.

@CharlesEkkel
Copy link
Author

CharlesEkkel commented Sep 27, 2024

Of course, as you point out, I could just not use GHC2024. But I do like it :). And yes you were quite right, I was missing a cabal update.

@develop7
Copy link
Collaborator

develop7 commented Dec 2, 2024

Let me try upgrading cabal there; 3.12 should be out for a while now

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