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

installed package ghc-9.0.1 is broken due to missing package exceptions-0.10.4 #1177

Closed
locallycompact opened this issue Jul 27, 2021 · 19 comments
Labels
bug Something isn't working

Comments

@locallycompact
Copy link
Contributor

Hi, I encountered this while converting a stack project that used ghc-tcplugins-extra, and it seems due to the dependency on ghc-9.0.1

Error:
    The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
installed package ghc-9.0.1 is broken due to missing package exceptions-0.10.4

Here is a repo reproducing the behaviour with nix-build.

https://github.com/locallycompact/haskell-nix-ghc-bug

@locallycompact locallycompact changed the title Failure to build ghc-9.0.1 when building a plugin. installed package ghc-9.0.1 is broken due to missing package exceptions-0.10.4 Aug 2, 2021
@hamishmack
Copy link
Collaborator

Best fix for this would be to set reinstallableLibGhc, but that does not work with GHC 9.0.1 yet. For now this should work:

 in pkgs.haskell-nix.project {
   # 'cleanGit' cleans a source directory based on the files known by git
   src = pkgs.haskell-nix.haskellLib.cleanGit {
     name = "haskell-nix-project";
     src = ./.;
   };
+  modules = [{
+    nonReinstallablePkgs = [
+      "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
+      "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
+      # ghcjs custom packages
+      "ghcjs-prim" "ghcjs-th"
+      "ghc-bignum" "exceptions" "stm"
+      "ghc-boot"
+      "ghc" "Cabal" "Win32" "array" "binary" "bytestring" "containers"
+      "directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim"
+      # "ghci" "haskeline"
+      "hpc"
+      "mtl" "parsec" "process" "text" "time" "transformers"
+      "unix" "xhtml" "terminfo"
+    ];
+  }];
 }

@miuirussia
Copy link
Contributor

miuirussia commented Jan 8, 2022

Same with ghc921

https://github.com/miuirussia/nix-flake-env/runs/4749352662?check_suite_focus=true

hie-compat-lib-hie-compat> Configuring library for hie-compat-0.2.1.0..
hie-compat-lib-hie-compat> Error:
hie-compat-lib-hie-compat>     The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
hie-compat-lib-hie-compat> installed package ghc-9.2.1 is broken due to missing package exceptions-0.10.4
error: builder for '/nix/store/n3d913nihb3s2kjywdvhlndlkmwri6s3-hie-compat-lib-hie-compat-0.2.1.0.drv' failed with exit code 1;
       last 10 log lines:
       > source root is source
       > patching sources
       > configuring
       > Configure flags:
       > --prefix=/nix/store/xrm2p8k2mdvj3wzxk89wfhw17lh4lprg-hie-compat-lib-hie-compat-0.2.1.0 lib:hie-compat --package-db=clear --package-db=/nix/store/01z7bcb96nw7zn94yhgx6w3a5zzsii2j-hie-compat-lib-hie-compat-0.2.1.0-config/lib/ghc-9.2.1/package.conf.d --flags=-ghc-lib --exact-configuration --dependency=rts=rts --dependency=ghc-heap=ghc-heap-9.2.1 --dependency=ghc-prim=ghc-prim-0.8.0 --dependency=integer-gmp=integer-gmp-1.1 --dependency=base=base-4.16.0.0 --dependency=deepseq=deepseq-1.4.6.0 --dependency=array=array-0.5.4.0 --dependency=ghc-boot-th=ghc-boot-th-9.2.1 --dependency=pretty=pretty-1.1.3.6 --dependency=template-haskell=template-haskell-2.18.0.0 --dependency=ghc-bignum=ghc-bignum-1.2 --dependency=ghc-boot=ghc-boot-9.2.1 --dependency=ghc=ghc-9.2.1 --dependency=Cabal=Cabal-3.6.0.0 --dependency=array=array-0.5.4.0 --dependency=binary=binary-0.8.9.0 --dependency=bytestring=bytestring-0.11.1.0 --dependency=containers=containers-0.6.5.1 --dependency=directory=directory-1.3.6.2 --dependency=filepath=filepath-1.4.2.1 --dependency=ghc-boot=ghc-boot-9.2.1 --dependency=ghc-compact=ghc-compact-0.1.0.0 --dependency=ghc-prim=ghc-prim-0.8.0 --dependency=hpc=hpc-0.6.1.0 --dependency=mtl=mtl-2.2.2 --dependency=parsec=parsec-3.1.14.0 --dependency=process=process-1.6.13.2 --dependency=text=text-1.2.5.0 --dependency=time=time-1.11.1.1 --dependency=transformers=transformers-0.5.6.2 --dependency=unix=unix-2.7.2.2 --dependency=xhtml=xhtml-3000.2.2.1 --dependency=terminfo=terminfo-0.4.1.5 --with-ghc=ghc --with-ghc-pkg=ghc-pkg --with-hsc2hs=hsc2hs --with-gcc=cc --with-ld=ld --with-ar=ar --with-strip=strip --disable-executable-stripping --disable-library-stripping --disable-library-profiling --disable-profiling --enable-static --enable-shared --disable-coverage --enable-library-for-ghci --datadir=/nix/store/s595v4206h9da48cgyjzklkk35n6l80s-hie-compat-lib-hie-compat-0.2.1.0-data/share/ghc-9.2.1

@angerman
Copy link
Collaborator

angerman commented Jan 8, 2022

@miuirussia does the proposed solution from @hamishmack work for 9.2.1?

@miuirussia
Copy link
Contributor

no, and on 9.0.1 not working too

@angerman
Copy link
Collaborator

angerman commented Jan 8, 2022

I see. Thanks. So this will need some investigation. Sorry for the inconvenience.

@avnik
Copy link

avnik commented Feb 10, 2022

@angerman it works for me on 9.2.1 (today's snapshot of haskell.nix -- 82a20b7). Used example above with omitted ghcjs stuff, and disabled hoogle).

@dhess
Copy link
Contributor

dhess commented Mar 28, 2022

FYI, we're running into this issue now with latest haskell.nix and GHC 9.2.2. I think @hamishmack's workaround is working for us, though it's too early to be sure as we're running into other GHC 9.2-related issues and haven't been able to get a full build working just yet.

@RichardWarfield
Copy link

This also occurs for us with GHC 9.0.2 and GHC 9.2.2 when haskell-language-server is added to shell.tools. The nonReinstallablePkgs workaround is not working; we still see installed package ghc-9.0.2 is broken due to missing package exceptions-0.10.4.

@goertzenator
Copy link
Contributor

This fix made polysemy-plugin and cleff-plugin work under ghc-9, but I am still having the same haskell-language-server problems as @RichardWarfield .

@TerrorJack
Copy link
Contributor

After #1437 got merged, I managed to build haskell-language-server with ghc922 using only reinstallableLibGhc = true module, without specifying a long list of nonReinstallablePkgs.

@goertzenator
Copy link
Contributor

Correction: I do have the merge from #1437 but hls is failing for reasons other than missing exceptions.

The failing project is https://github.com/goertzenator/hnixtest. This is on a default "stack new" project with polysemy and cleff added (w/plugins). The project builds just fine, but I can't get haskell-language-server when I run nix-shell.

This is the failing nix-shell output.

@hamishmack
Copy link
Collaborator

Try removing this bit. One of the things reinstallableLibGhc = true does is it changes the default for nonReinstallablePkgs.

@goertzenator
Copy link
Contributor

Thanks. I removed that along with the cleff/polysemy stuff (true default stack project now) but it did not work. Full output. The repo has been updated with these changes.

To summarize, hiedb (required by haskell-language-server) wants base <4.16, but the base present is 4.16.1.0 so the build fails.

@jkopanski
Copy link
Contributor

jkopanski commented Apr 30, 2022

it seems that haskell-language-server is using custm cabal.project for ghc92. It has allow-never: hiedb:base inside.

So I basically copied it into tool.haskell-language-server.cabalProject in order to mitigate fail that you mention @goertzenator.

However that only got me so far as now it complains about missing hls plugins or wrong versions.

cabal: Could not resolve dependencies:
[__0] trying: haskell-language-server-1.7.0.0 (user goal)
[__1] trying: haskell-language-server:+changetypesignature
[__2] unknown package: hls-change-type-signature-plugin (dependency of
haskell-language-server +changetypesignature)
[__2] fail (backjumping, conflict set: haskell-language-server,
hls-change-type-signature-plugin, haskell-language-server:changetypesignature)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: haskell-language-server,
haskell-language-server:changetypesignature, hls-change-type-signature-plugin

Unable to find component haskell-language-server:exe:haskell-language-server due to the above cabal configuration error

Disabling this plugin in cabalProject just makes it complain about next one.

// EDIT

I just took another look at it and my woes were because I missed the index-state in the cabal.project. Removing that and I've managed to successfully build hls.

@dhess
Copy link
Contributor

dhess commented Apr 30, 2022

@jkopanski Would you mind posting your literal tool.haskell-language-server.cabalProject that makes this work?

@jkopanski
Copy link
Contributor

this is my shell.nix

@dhess
Copy link
Contributor

dhess commented May 28, 2022

This is not a complaint, just a request for clarification. This issue has been present for 10 months now, and it's affecting not only our own app when built with GHC 9.2.2, but also now both the latest versions of weeder and hlint which otherwise support GHC 9.2.x.

What's the root cause, and is there any hope of this being fixed in the near future?

dhess added a commit to hackworthltd/primer that referenced this issue Jun 6, 2022
We temporarily pull from
github:July541/haskell-language-server/ghc-9.2.3, until this PR is
merged upstream:

haskell/haskell-language-server#2936

However, more importantly, we re-use the `nonReinstallablePkgs` from
input-output-hk/haskell.nix#1177 to fix a
crash that has been plaguing us since we switched the GHC 9.2.3.
@L-as
Copy link
Contributor

L-as commented Sep 1, 2022

bump

@yvan-sraka yvan-sraka added the bug Something isn't working label Sep 20, 2022
@hamishmack
Copy link
Collaborator

As far as I know this is fixed and the work arounds are not needed any more (since reinstallableLibGhc is now the default).

To check I built the tools mentioned using the latest haskell.nix and both ghc 9.0 and 9.2:

nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc902" "hlint" "3.4.1")'
nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc902" "weeder" "2.3.1")'
nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc902" "haskell-language-server" "1.8.0.0")'
nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc924" "hlint" "3.4.1")'
nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc924" "weeder" "2.4.0")'
nix-build -E '((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc924" "haskell-language-server" "1.8.0.0")'

In the original repo https://github.com/locallycompact/haskell-nix-ghc-bug with the patch below applied to update it. I ran:

nix-build . -A hsPkgs.haskell-nix-ghc-bug.components.library
diff --git a/default.nix b/default.nix
index bfcd208..7b55695 100644
--- a/default.nix
+++ b/default.nix
@@ -14,7 +14,7 @@ let
     # haskell.nix provides access to the nixpkgs pins which are used by our CI,
     # hence you will be more likely to get cache hits when using these.
     # But you can also just use your own, e.g. '<nixpkgs>'.
-    haskellNix.sources.nixpkgs-2105
+    haskellNix.sources.nixpkgs-unstable
     # These arguments passed to nixpkgs, include some patches and also
     # the haskell.nix functionality itself as an overlay.
     haskellNix.nixpkgsArgs;
diff --git a/nix/sources.json b/nix/sources.json
index f8a0e6d..c254a80 100644
--- a/nix/sources.json
+++ b/nix/sources.json
@@ -5,10 +5,10 @@
         "homepage": "https://input-output-hk.github.io/haskell.nix",
         "owner": "input-output-hk",
         "repo": "haskell.nix",
-        "rev": "97421c99a9a1843e88e6e8937ed683d59eedc74e",
-        "sha256": "0c7g8akcrqds4rkpiczk047riryk2hzllv75dlbjyy76qzxwyhr3",
+        "rev": "9c20232d0fc5577932ba3ee4dd277278b4c3bf48",
+        "sha256": "125v89dij1n58mzvb7rffkb93790vqljc9b780rw9d3x21w3qq4r",
         "type": "tarball",
-        "url": "https://github.com/input-output-hk/haskell.nix/archive/97421c99a9a1843e88e6e8937ed683d59eedc74e.tar.gz",
+        "url": "https://github.com/input-output-hk/haskell.nix/archive/9c20232d0fc5577932ba3ee4dd277278b4c3bf48.tar.gz",
         "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
     },
     "niv": {
diff --git a/stack.yaml b/stack.yaml
index 4f7d497..9e4f976 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -1,4 +1,4 @@
-resolver: nightly-2021-07-23
+resolver: nightly-2022-09-17
 packages:
 - .
 extra-deps: []

dhess added a commit to hackworthltd/primer that referenced this issue Sep 24, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 1, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 4, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 14, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 14, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 14, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.

And one more thing: we need to disable the NixOS test framework for
the time being until I can port it to the next NixOS test system.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 14, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.

And one more thing: we need to disable the NixOS test framework for
the time being until I can port it to the next NixOS test system.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 15, 2022
Switch back to the haskell.nix-provided HLS.

Also, we can undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.

And one more thing: we need to disable the NixOS test framework for
the time being until I can port it to the next NixOS test system.
dhess added a commit to hackworthltd/primer that referenced this issue Oct 15, 2022
Also, we make the following changes:

* Switch back to the haskell.nix-provided HLS.

* Undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.

* disable the NixOS test framework for the time being until I can port
it to the next NixOS test system.

* Switch to fourmolu 0.8.2 as building 0.7 causes a segfault on
`aarch64-darwin`, all of a sudden.

* Reformat our Cabal files using the latest `cabal-fmt`.

* Drop the GHC 8.10.7 workaround for `cabal-fmt`.

* Drop `cabal-edit` from our toolset, as it produces bad PVP bounds,
and has apparently been abandoned upstream. See
sdiehl/cabal-edit#6
dhess added a commit to hackworthltd/primer that referenced this issue Oct 15, 2022
Also, we make the following changes:

* Switch back to the haskell.nix-provided HLS.

* Undo the workarounds needed for
input-output-hk/haskell.nix#1177 as that
issue has now been fixed upstream.

* disable the NixOS test framework for the time being until I can port
it to the next NixOS test system.

* Switch to fourmolu 0.8.2 as building 0.7 causes a segfault on
`aarch64-darwin`, all of a sudden.

* Reformat our Cabal files using the latest `cabal-fmt`.

* Drop the GHC 8.10.7 workaround for `cabal-fmt`.

* Drop `cabal-edit` from our toolset, as it produces bad PVP bounds,
and has apparently been abandoned upstream. See
sdiehl/cabal-edit#6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.