haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

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

Open locallycompact opened this issue 4 years ago • 17 comments

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 avatar Jul 27 '21 07:07 locallycompact

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"
+    ];
+  }];
 }

hamishmack avatar Aug 03 '21 06:08 hamishmack

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

miuirussia avatar Jan 08 '22 18:01 miuirussia

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

angerman avatar Jan 08 '22 23:01 angerman

no, and on 9.0.1 not working too

miuirussia avatar Jan 08 '22 23:01 miuirussia

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

angerman avatar Jan 08 '22 23:01 angerman

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

avnik avatar Feb 10 '22 14:02 avnik

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.

dhess avatar Mar 28 '22 22:03 dhess

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.

RichardWarfield avatar Apr 18 '22 19:04 RichardWarfield

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 .

goertzenator avatar Apr 21 '22 20:04 goertzenator

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.

TerrorJack avatar Apr 21 '22 20:04 TerrorJack

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.

goertzenator avatar Apr 21 '22 21:04 goertzenator

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

hamishmack avatar Apr 22 '22 02:04 hamishmack

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.

goertzenator avatar Apr 22 '22 21:04 goertzenator

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.

jkopanski avatar Apr 30 '22 10:04 jkopanski

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

dhess avatar Apr 30 '22 11:04 dhess

this is my shell.nix

jkopanski avatar Apr 30 '22 12:04 jkopanski

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 avatar May 28 '22 13:05 dhess

bump

L-as avatar Sep 01 '22 13:09 L-as

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: []

hamishmack avatar Sep 20 '22 12:09 hamishmack