haskell / vscode-haskell

VS Code extension for Haskell, powered by haskell-language-server
https://marketplace.visualstudio.com/items?itemName=haskell.haskell
Other
561 stars 90 forks source link

“GHC ABIs don’t match!” #1005

Closed aryairani closed 5 months ago

aryairani commented 10 months ago

Sorry, I've read https://github.com/haskell/vscode-haskell#ghc-abis-dont-match and https://www.haskell.org/ghcup/guide/#stack-integration, and have ghcup hooks for stack (though I don't think I need them, because i have the right ghc in my path?), but I'm still getting this error confusingly.

Your environment

Which OS do you use:

MacOS

Steps to reproduce

Install GHCup w/ Stack hooks

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Install nix also (sorry; but maybe we can find a solution without you having to install nix if you prefer not to)

-- get the stack project
% git clone git@github.com:unisonweb/unison
-- put ghc 9.2.8 on the path
-- put hls for ghc 9.2.8 on the path
-- put stack "--no-nix" "--system-ghc" "--no-install-ghc" on the path
% nix develop
$ haskell-language-server-wrapper --lsp
:explosion:

Maybe relevant:

$ which ghc
/nix/store/z4sncngyn900gl89v9dfljhg3j81zsal-ghc-9.2.8/bin/ghc

$ stack exec -- which ghc
/nix/store/z4sncngyn900gl89v9dfljhg3j81zsal-ghc-9.2.8/bin/ghc

So I have the matching ghc on my path here, and stack seems to be able to find it. But hls-wrapper is somehow finding a ghcup-installed ghc 9.4.7.

Any ideas how I can fix or diagnose better?

Thank you!

Expected behaviour

Successful HLS LSP startup

Actual behaviour

“GHC ABIs don’t match!”

Include debug information

Execute in the root of your project the command haskell-language-server-wrapper --debug . and paste the logs here (you can find the executable location here):

Debug output: ``` Found "/Users/arya/work/unison/.trunk-pristine/hie.yaml" for "/Users/arya/work/unison/.trunk-pristine/a" Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.4.0.0 aarch64 ghc-9.2.8 Current directory: /Users/arya/work/unison/.trunk-pristine Operating system: darwin Arguments: ["--debug"] Cradle directory: /Users/arya/work/unison/.trunk-pristine Cradle type: Stack Tool versions found on the $PATH cabal: 3.6.2.1 stack: 2.13.1 ghc: 9.4.7 Consulting the cradle to get project GHC version... 2023-12-02T15:06:24.455062Z | Debug | executing command: stack setup --silent 2023-12-02T15:06:25.360768Z | Debug | executing command: stack exec ghc -- --numeric-version Project GHC version: 9.2.8 haskell-language-server exe candidates: ["haskell-language-server-9.2.8","haskell-language-server"] Launching haskell-language-server exe at:/nix/store/gbrsg153bxxx6f3g3qwddnj8a0cc30c5-haskell-language-server-2.4.0.0/bin/haskell-language-server-9.2.8 2023-12-02T15:06:25.840719Z | Debug | executing command: stack setup --silent 2023-12-02T15:06:26.742646Z | Debug | executing command: stack exec ghc -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2023-12-02T15:06:27.415082Z | Debug | executing command: stack setup --silent 2023-12-02T15:06:28.301413Z | Debug | executing command: stack exec ghc -- --print-libdir GHC ABIs don't match!  Expected: Cabal-3.6.3.0:0e1821a328af5568ecac0d7fc0c122ba array-0.5.4.0:4b2142702196aa5800165b234aa4dcfd base-4.16.4.0:660df90750812c0c4e3194d20dac941b binary-0.8.9.0:383dd2eb949b3ac340df8947be1653d3 bytestring-0.11.4.0:f1a1eeb8ecb9d870fd421abc52dd16d3 containers-0.6.5.1:ff67d27d565264dd93b0885417b524af deepseq-1.4.6.1:7a884f02a284df028cba6e374f48b08c directory-1.3.6.2:8c94a2661fc08cb1e0bcaee5cf3ddf7d exceptions-0.10.4:b20991d8f250575e0d7db0e0fc64bb49 filepath-1.4.2.2:d6ab5cd15dfe12e976dc735f866207d6 ghc-9.2.8:b12a80b7e66b9ea7eb0a0c3f4d05032f ghc-bignum-1.2:4bf6905ca8cca85ad75c30d36c11b21d ghc-boot-9.2.8:9515f9da9f5429aa8f0f33ee6b7826c3 ghc-boot-th-9.2.8:0459167572d09529e9ad209950f37353 ghc-compact-0.1.0.0:b18f0e252bf3a0ae7ce5231e8ca29b12 ghc-heap-9.2.8:dda1098b248deb996be0b318915435e6 ghc-prim-0.8.0:8fcacaf0e051765d2549d34af25d8721 ghci-9.2.8:659ce20145365c9f87a659bf33cfd843 haskeline-0.8.2:91ea8299dd101c3e17cd98a3ebf90b6b hpc-0.6.1.0:3c59c7353acbd2ede96ad182e68d5158 integer-gmp-1.1:a749a068f2405fe3a2c35cf42bac3b95 libiserv-9.2.8:c98070ad03e18073c59d4a1544428bc8 mtl-2.2.2:5e83d170ce421645194aebd4f28acfef parsec-3.1.15.0:1c67064627bcbbb2e35892484acadc26 pretty-1.1.3.6:6e88c9de227c6d1000e96d56416efc74 process-1.6.16.0:9d725028707ee0c87e46156af46daf94 rts-1.0.2: stm-2.5.0.2:3780ad6fd3b3a8c67113c49e7c1d0ef1 template-haskell-2.18.0.0:b964322023e91398c2a56ff1a003019f terminfo-0.4.1.5:97d5b1b4652448e27c7d37bca9bc0858 text-1.2.5.0:2c15007e9526ee3ef2a8b27da829f664 time-1.11.1.1:a31647dfdef7ff6981bc34e9d6148143 transformers-0.5.6.2:3b0a13331e15f843dd53735b93b2367d unix-2.7.2.2:a26d2b8b861c6d68575447075d16face xhtml-3000.2.2.1:7bba065d960f673c566d0eda6914f4ee Got: Cabal-3.6.3.0:8967536eba90a1016bb90699de5b0c47 array-0.5.4.0:4d91a3893c8bed5b267e4352abcc498e base-4.16.4.0:71dcebd1df5a4d5e9f9d3d93c7dd10ae binary-0.8.9.0:1970ebf650a64c37eb5b15c31aea8159 bytestring-0.11.4.0:ed9fbfac0e59d5f523f8b3f86d7951a0 containers-0.6.5.1:2f7b1a9c501414075f717af41b1c8ab3 deepseq-1.4.6.1:f0ad76b820eb62b601d23f6f7bcbb80f directory-1.3.6.2:cb0759c36a2730c2fa6d6ddf16d752e2 exceptions-0.10.4:3bf5f53a1b3e95efac254c41b8d2bcf8 filepath-1.4.2.2:957cb16b4564322b979b2fd6467a5ea5 ghc-9.2.8:79f079de80e619681570f5ef4fc7a0ec ghc-bignum-1.2:4bf6905ca8cca85ad75c30d36c11b21d ghc-boot-9.2.8:5e55b29e9b0cde7be994cb34486b230b ghc-boot-th-9.2.8:7d1b25209b54c68b99de4a1be151729d ghc-compact-0.1.0.0:ec71ccd54dceccc82aaf5ca6d8b801c8 ghc-heap-9.2.8:d0a56124519485874338037fea6c44d7 ghc-prim-0.8.0:8fcacaf0e051765d2549d34af25d8721 ghci-9.2.8:490e33e54f839b54b43505851333180a haskeline-0.8.2:1a4eacb91934e1c40509eb38ed9617e5 hpc-0.6.1.0:a023ec7a3f50bae93120544e821dab94 integer-gmp-1.1:21c20ffd2095a30619d4848fb1392323 libiserv-9.2.8:b5ef2bd89dcb3b15852b5c23d1620697 mtl-2.2.2:d620122b64a121900ab3b0a4d2f87db3 parsec-3.1.15.0:823cbaeb4f0d8985211518b42def5662 pretty-1.1.3.6:9dec267eb4167b74720b16da8c6f7a48 process-1.6.16.0:229b9547cac64d26c04f74c8a204cb28 rts-1.0.2:2881cf8549be49b0dd5a86a4989e8cd2 stm-2.5.0.2:d46401b837a8d291ba4ace8d08d288b1 template-haskell-2.18.0.0:c253d5c0d78466d31783c7c9e6a0731a terminfo-0.4.1.5:b409ea0fdad72de091fff2958f6c104f text-1.2.5.0:afb3956334cd675167fd46d1acc0e806 time-1.11.1.1:66e8c747b0ee779c7e0390a1f81a97b5 transformers-0.5.6.2:902b1ce4e62013e852c6e5d6a424e74c unix-2.7.2.2:875b492620c406f61a1bc48c67fe5bb2 xhtml-3000.2.2.1:c92cbe3774cd98f9cdccbb9408ba5a58 Content-Length: 203 {"jsonrpc":"2.0", "method":"window/showMessage", "params": {"type": 1, "message": "Couldn't find a working/matching GHC installation. Visit https://nixos.org/manual/nixpkgs/unstable/#haskell-language-server to learn how to correctly install a matching hls for your ghc with nix."}} ```

Paste the contents of extension specific log, you can check instructions about how to find it here

Extension log: ``` 2023-12-02 15:08:02.7990000 [client] DEBUG Environment variables: 2023-12-02 15:08:02.8010000 [client] DEBUG PATH: /nix/store/bj0cf6i8c5q5yf67v7033b3f9an6av90-ormolu-0.5.2.0/bin:/nix/store/gbrsg153bxxx6f3g3qwddnj8a0cc30c5-haskell-language-server-2.4.0.0/bin:/nix/store/9b0x00852cisghh91p75pl0ihnks0vjk-stack-2.13.1/bin:/nix/store/8j9nghc4846a2ali03z0ijp1rgqv9jby-hpack-0.35.2/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0/bin:/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10/bin:/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9/bin:/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11/bin:/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2/bin:/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35/bin:/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13/bin:/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin/bin:/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1/bin:/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin:/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6/bin:/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin/bin:/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45/bin:/Users/arya/.cabal/bin:/Users/arya/.ghcup/bin:/Users/arya/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Users/arya/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin 2023-12-02 15:08:02.8010000 [client] INFO Finding haskell-language-server 2023-12-02 15:08:02.8010000 [client] INFO Searching for server executables haskell-language-server-wrapper,haskell-language-server in $PATH 2023-12-02 15:08:02.8010000 [client] INFO $PATH environment variable: /nix/store/bj0cf6i8c5q5yf67v7033b3f9an6av90-ormolu-0.5.2.0/bin:/nix/store/gbrsg153bxxx6f3g3qwddnj8a0cc30c5-haskell-language-server-2.4.0.0/bin:/nix/store/9b0x00852cisghh91p75pl0ihnks0vjk-stack-2.13.1/bin:/nix/store/8j9nghc4846a2ali03z0ijp1rgqv9jby-hpack-0.35.2/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0/bin:/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10/bin:/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9/bin:/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11/bin:/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2/bin:/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35/bin:/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13/bin:/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin/bin:/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1/bin:/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin:/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6/bin:/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin/bin:/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45/bin:/Users/arya/.cabal/bin:/Users/arya/.ghcup/bin:/Users/arya/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Users/arya/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin 2023-12-02 15:08:02.8040000 [client] INFO Found server executable in $PATH: haskell-language-server-wrapper 2023-12-02 15:08:02.8040000 [client] INFO Activating the language server in working dir: /Users/arya/work/unison/.trunk-pristine (the workspace folder) 2023-12-02 15:08:02.8040000 [client] INFO run command: haskell-language-server-wrapper --lsp -d 2023-12-02 15:08:02.8040000 [client] INFO debug command: haskell-language-server-wrapper --lsp -d 2023-12-02 15:08:02.8040000 [client] INFO server environment variables: 2023-12-02 15:08:02.8040000 [client] DEBUG document selector patten: /Users/arya/work/unison/.trunk-pristine/**/* 2023-12-02 15:08:02.8050000 [client] INFO Starting language server [Trace - 10:08:02 AM] Sending request 'initialize - (0)'. Found "/Users/arya/work/unison/.trunk-pristine/hie.yaml" for "/Users/arya/work/unison/.trunk-pristine/a" Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.4.0.0 aarch64 ghc-9.2.8 Current directory: /Users/arya/work/unison/.trunk-pristine Operating system: darwin Arguments: ["--lsp","-d"] Cradle directory: /Users/arya/work/unison/.trunk-pristine Cradle type: Stack Tool versions found on the $PATH cabal: 3.6.2.1 stack: 2.13.1 ghc: 9.4.7 Consulting the cradle to get project GHC version... 2023-12-02T15:08:03.199510Z | Debug | executing command: stack setup --silent 2023-12-02T15:08:04.420407Z | Debug | executing command: stack exec ghc -- --numeric-version Project GHC version: 9.2.8 haskell-language-server exe candidates: ["haskell-language-server-9.2.8","haskell-language-server"] Launching haskell-language-server exe at:/nix/store/gbrsg153bxxx6f3g3qwddnj8a0cc30c5-haskell-language-server-2.4.0.0/bin/haskell-language-server-9.2.8 2023-12-02T15:08:04.955924Z | Debug | executing command: stack setup --silent 2023-12-02T15:08:05.890273Z | Debug | executing command: stack exec ghc -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2023-12-02T15:08:06.638932Z | Debug | executing command: stack setup --silent 2023-12-02T15:08:07.609261Z | Debug | executing command: stack exec ghc -- --print-libdir GHC ABIs don't match!  Expected: Cabal-3.6.3.0:0e1821a328af5568ecac0d7fc0c122ba array-0.5.4.0:4b2142702196aa5800165b234aa4dcfd base-4.16.4.0:660df90750812c0c4e3194d20dac941b binary-0.8.9.0:383dd2eb949b3ac340df8947be1653d3 bytestring-0.11.4.0:f1a1eeb8ecb9d870fd421abc52dd16d3 containers-0.6.5.1:ff67d27d565264dd93b0885417b524af deepseq-1.4.6.1:7a884f02a284df028cba6e374f48b08c directory-1.3.6.2:8c94a2661fc08cb1e0bcaee5cf3ddf7d exceptions-0.10.4:b20991d8f250575e0d7db0e0fc64bb49 filepath-1.4.2.2:d6ab5cd15dfe12e976dc735f866207d6 ghc-9.2.8:b12a80b7e66b9ea7eb0a0c3f4d05032f ghc-bignum-1.2:4bf6905ca8cca85ad75c30d36c11b21d ghc-boot-9.2.8:9515f9da9f5429aa8f0f33ee6b7826c3 ghc-boot-th-9.2.8:0459167572d09529e9ad209950f37353 ghc-compact-0.1.0.0:b18f0e252bf3a0ae7ce5231e8ca29b12 ghc-heap-9.2.8:dda1098b248deb996be0b318915435e6 ghc-prim-0.8.0:8fcacaf0e051765d2549d34af25d8721 ghci-9.2.8:659ce20145365c9f87a659bf33cfd843 haskeline-0.8.2:91ea8299dd101c3e17cd98a3ebf90b6b hpc-0.6.1.0:3c59c7353acbd2ede96ad182e68d5158 integer-gmp-1.1:a749a068f2405fe3a2c35cf42bac3b95 libiserv-9.2.8:c98070ad03e18073c59d4a1544428bc8 mtl-2.2.2:5e83d170ce421645194aebd4f28acfef parsec-3.1.15.0:1c67064627bcbbb2e35892484acadc26 pretty-1.1.3.6:6e88c9de227c6d1000e96d56416efc74 process-1.6.16.0:9d725028707ee0c87e46156af46daf94 rts-1.0.2: stm-2.5.0.2:3780ad6fd3b3a8c67113c49e7c1d0ef1 template-haskell-2.18.0.0:b964322023e91398c2a56ff1a003019f terminfo-0.4.1.5:97d5b1b4652448e27c7d37bca9bc0858 text-1.2.5.0:2c15007e9526ee3ef2a8b27da829f664 time-1.11.1.1:a31647dfdef7ff6981bc34e9d6148143 transformers-0.5.6.2:3b0a13331e15f843dd53735b93b2367d unix-2.7.2.2:a26d2b8b861c6d68575447075d16face xhtml-3000.2.2.1:7bba065d960f673c566d0eda6914f4ee Got: Cabal-3.6.3.0:8967536eba90a1016bb90699de5b0c47 array-0.5.4.0:4d91a3893c8bed5b267e4352abcc498e base-4.16.4.0:71dcebd1df5a4d5e9f9d3d93c7dd10ae binary-0.8.9.0:1970ebf650a64c37eb5b15c31aea8159 bytestring-0.11.4.0:ed9fbfac0e59d5f523f8b3f86d7951a0 containers-0.6.5.1:2f7b1a9c501414075f717af41b1c8ab3 deepseq-1.4.6.1:f0ad76b820eb62b601d23f6f7bcbb80f directory-1.3.6.2:cb0759c36a2730c2fa6d6ddf16d752e2 exceptions-0.10.4:3bf5f53a1b3e95efac254c41b8d2bcf8 filepath-1.4.2.2:957cb16b4564322b979b2fd6467a5ea5 ghc-9.2.8:79f079de80e619681570f5ef4fc7a0ec ghc-bignum-1.2:4bf6905ca8cca85ad75c30d36c11b21d ghc-boot-9.2.8:5e55b29e9b0cde7be994cb34486b230b ghc-boot-th-9.2.8:7d1b25209b54c68b99de4a1be151729d ghc-compact-0.1.0.0:ec71ccd54dceccc82aaf5ca6d8b801c8 ghc-heap-9.2.8:d0a56124519485874338037fea6c44d7 ghc-prim-0.8.0:8fcacaf0e051765d2549d34af25d8721 ghci-9.2.8:490e33e54f839b54b43505851333180a haskeline-0.8.2:1a4eacb91934e1c40509eb38ed9617e5 hpc-0.6.1.0:a023ec7a3f50bae93120544e821dab94 integer-gmp-1.1:21c20ffd2095a30619d4848fb1392323 libiserv-9.2.8:b5ef2bd89dcb3b15852b5c23d1620697 mtl-2.2.2:d620122b64a121900ab3b0a4d2f87db3 parsec-3.1.15.0:823cbaeb4f0d8985211518b42def5662 pretty-1.1.3.6:9dec267eb4167b74720b16da8c6f7a48 process-1.6.16.0:229b9547cac64d26c04f74c8a204cb28 rts-1.0.2:2881cf8549be49b0dd5a86a4989e8cd2 stm-2.5.0.2:d46401b837a8d291ba4ace8d08d288b1 template-haskell-2.18.0.0:c253d5c0d78466d31783c7c9e6a0731a terminfo-0.4.1.5:b409ea0fdad72de091fff2958f6c104f text-1.2.5.0:afb3956334cd675167fd46d1acc0e806 time-1.11.1.1:66e8c747b0ee779c7e0390a1f81a97b5 transformers-0.5.6.2:902b1ce4e62013e852c6e5d6a424e74c unix-2.7.2.2:875b492620c406f61a1bc48c67fe5bb2 xhtml-3000.2.2.1:c92cbe3774cd98f9cdccbb9408ba5a58 [Error - 10:08:09 AM] Connection to server is erroring. Shutting down server. [Trace - 10:08:09 AM] Sending request 'shutdown - (1)'. [Error - 10:08:09 AM] Connection to server is erroring. Shutting down server. ```
fendor commented 10 months ago

Hi!

Quick question, if you develop via nix, how does ghcup factor in here? Iirc, the nix shell should put its own stack binary on the PATH?

aryairani commented 10 months ago

Hi @fendor,

Quick question, if you develop via nix, how does ghcup factor in here?

I'm not totally sure if it does factor in. I just mention it a) because the docs mention it, and b) because hls --lsp seems to be finding the ghcup-installed ghc of the wrong version even though I have a nix-provided ghc of the right version.

Iirc, the nix shell should put its own stack binary on the PATH?

This is true, but for what it's worth, the nix-provided stack binary still sees the ghcup hooks in my ~/.stack/hooks. As far as I know (limited) it should ignore these though since I pass --system-ghc. So I'm not sure if this matters.

fendor commented 10 months ago

I tried building unison from source but on arch linux within a nix develop shell, stack crashes with the message:

Log files have been written to: /home/hugin/Documents/haskell/unison/.stack-work/logs/
Progress 197/316

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package zlib-0.6.3.0 (scroll up to its section to see the error) using:
       /home/hugin/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_9p6GVs8J_3.6.3.0_ghc-9.2.8 --verbose=1 --builddir=.stack-work/dist/x86_64-linux/ghc-9.2.8 configure --with-ghc=/nix/store/p9217wymlc3yz2r8lxzwrwlwasl2khzm-ghc-9.2.8/bin/ghc-9.2.8 --with-ghc-pkg=/nix/store/p9217wymlc3yz2r8lxzwrwlwasl2khzm-ghc-9.2.8/bin/ghc-pkg-9.2.8 --user --package-db=clear --package-db=global --package-db=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/pkgdb --libdir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/lib --bindir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/bin --datadir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/share --libexecdir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/libexec --sysconfdir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/etc --docdir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/doc/zlib-0.6.3.0 --htmldir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/doc/zlib-0.6.3.0 --haddockdir=/home/hugin/.stack/snapshots/x86_64-linux/e81f16955d1eaa42f615487e8ca1445eb8efc22447f1b1f153c7d149148f1a5e/9.2.8/doc/zlib-0.6.3.0 --dependency=base=base-4.16.4.0 --dependency=bytestring=bytestring-0.11.4.0 -f-bundled-c-zlib -f-non-blocking-ffi -f-pkg-config --ghc-options -haddock --exact-configuration --ghc-option=-fhide-source-paths
       Process exited with code: ExitFailure 1 
       Logs have been written to: /home/hugin/Documents/haskell/unison/.stack-work/logs/zlib-0.6.3.0.log

       Configuring zlib-0.6.3.0...
       Cabal-simple_9p6GVs8J_3.6.3.0_ghc-9.2.8: Missing dependency on a foreign
       library:
       * Missing (or bad) header file: zlib.h
       * Missing (or bad) C library: z
       This problem can usually be solved by installing the system package that
       provides this library (you may need the "-dev" version). If the library is
       already installed but in a non-standard location then you can use the flags
       --extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
       library file does exist, it may contain errors that are caught by the C
       compiler at the preprocessing stage. In this case you can re-run configure
       with the verbosity flag -v3 to see the error messages.
       If the header file does exist, it may contain errors that are caught by the C
       compiler at the preprocessing stage. In this case you can re-run configure
       with the verbosity flag -v3 to see the error messages.

I am not sure, did you launch your editor via code . from the unison project root?

aryairani commented 10 months ago

Sorry about that @fendor. Does building the travis/nix-flake-c-deps branch resolve that for you? It resolves a similar error for me. That said, I'm on macOS so the situation may be different.

I don't necessarily launch my editor via code . from the unison project root, but I use the "direnv" vscode extension by Martin Kühl, and I put use flake into .envrc in the unison project root. I use the "Environment Variables" vscode extension by Necati ARSLAN to confirm that my PATH is set right, and it usually is.

fendor commented 10 months ago

The GHCup build hook... Can you compare the output of:

> stack exec ghc --print-libdir
> ghc-9.2.8 --print-libdir

I am thinking that the build hook you install with GHCup makes stack use the ghc binary of GHCup, not from nix which you absolutely need.

aryairani commented 10 months ago

But for what it's worth, when I'm running commands within the vscode terminal, it shouldn't matter how or whether I'm running vscode, should it? Everything relevant is contained within the terminal.

fendor commented 10 months ago

Yeah, your usage of the stack hooks would be incorrect outside and inside of VSCode if my theory is correct. However, only HLS may be performing ABI compatibility checks.

aryairani commented 10 months ago

Sorry I guess I didn't understand any part of the previous comment. I had been getting the same ABI errors both from the vscode log and from the terminal (I included them in the ticket). Or else, what's the theory?

fendor commented 10 months ago

My question was, what is the output of stack exec ghc --print-libdir and ghc-9.2.8 --print-libdir from within the nix develop shell. The outputs of both commands have to match exactly, but I am suspecting, that stack is picking up the ghc version installed by GHCup which is not the same as the one from nix develop. They have to match exactly.

cab404 commented 9 months ago

I guess I'll be necroposting here with pretty much the same bug on NixOS, with 2.5.0.0

ocapn-suite on  handoffs [$!?] via λ lts-21.25 via ❄️  impure (nix-shell-env)
+32%03:47δ haskell-language-server-wrapper -d --lsp
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(.haskell-language-server-wrapper) Version 2.5.0.0 x86_64 ghc-9.2.8
Current directory: /home/cab/data/work/ocapn/hs/ocapn-suite
Operating system: linux
Arguments: []
Cradle directory: /home/cab/data/work/ocapn/hs/ocapn-suite
Cradle type: Stack

Tool versions found on the $PATH
cabal:          Not found
stack:          2.13.1
ghc:            9.4.8

Consulting the cradle to get project GHC version...
2024-01-15T00:48:48.520257Z | Debug | executing command: stack setup --silent
2024-01-15T00:48:49.573821Z | Debug | executing command: stack exec ghc -- --numeric-version
Project GHC version: 9.4.8
haskell-language-server exe candidates: ["haskell-language-server-9.4.8","haskell-language-server"]
Launching haskell-language-server exe at:/home/cab/software/hls/haskell-language-server-2.5.0.0-x86_64-linux-unknown/out/usr/local/bin/haskell-language-server-9.4.8
2024-01-15T00:48:50.676448Z | Debug | executing command: stack setup --silent
2024-01-15T00:48:51.736392Z | Debug | executing command: stack exec ghc -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2024-01-15T00:48:52.897143Z | Debug | executing command: stack setup --silent
2024-01-15T00:48:53.954954Z | Debug | executing command: stack exec ghc -- --print-libdir
GHC ABIs don't match!

Expected: Cabal-3.8.1.0:ed264dfad51755add5ad1550cefc7305 Cabal-syntax-3.8.1.0:11937df3ce969a94a33e89d0ba965dbe array-0.5.4.0:41bd88e1446deebe13fe286fbd046e2f base-4.17.2.1:f4d022627de1581765f39b0c2ad71cc2 binary-0.8.9.1:946a6cd8d0e6ebf36dd8bfceb47ad345 bytestring-0.11.5.3:a56dda3d5aab2a1e83b83fccb62fdea8 containers-0.6.7:f936e4da14408ab8dc11ca33468e91f8 deepseq-1.4.8.0:24cb6772eecf6f899a035fdce71ae195 directory-1.3.7.1:51461b8d852b24c1046ec72981f9e81f exceptions-0.10.5:a3c9d003b54ff36840d118d5810824ac filepath-1.4.2.2:111cdc817f86d32fec10d4d7b857e516 ghc-9.4.8:708c7aab4bfa7ee4fde19d617911910d ghc-bignum-1.3:a01c7de8f9ebbcc26fa13f4de49cd9f8 ghc-boot-9.4.8:f297069f89ed2cc59cc83dc079f69c79 ghc-boot-th-9.4.8:8a0c756ad78fa20c3a0e97fc1da48798 ghc-compact-0.1.0.0:5f2639ff33c3e14dd4e7ec29575a05b6 ghc-heap-9.4.8:7be5fab155258065b609b65d383366bb ghc-prim-0.9.1:ffde7061cf7182b2d3ec5d68c5c91fdb ghci-9.4.8:7c68069bd8138fcf5b4cb838e8d273c1 haskeline-0.8.2:947715e05372203385efe7c9eeddd798 hpc-0.6.1.0:8e530db3ae1badf54b006083dd2c261f integer-gmp-1.1:e71963e48407810a53e9323cf1b2d9fc libiserv-9.4.8:0db636c5ea8006cd60b4256834e2d610 mtl-2.2.2:e360d4baab21de5d0e6716d01fb48606 parsec-3.1.16.1:0c889a9c907717d0c0ddf464115dbc93 pretty-1.1.3.6:431df84361ffc7a6da4dddf4636b7e25 process-1.6.18.0:5df50172ffefee5d20f92d3f6f8c6b33 rts-1.0.2:12d776480acf79c658d9432f8261bf55 stm-2.5.1.0:c47763c9c60a781a50a6f52175dbdc63 system-cxx-std-lib-1.0:00000000000000000000000000000000 template-haskell-2.19.0.0:c7020a3b4fcdf8b13d08b53ab80c87ff terminfo-0.4.1.5:d35174ed0e58934db2cdd6c529096669 text-2.0.2:176dddc9ce896cb54bf1ca9a3737a966 time-1.12.2:9f2ea07607e17c6ee857ccc49d48cd9d transformers-0.5.6.2:6263a3b644b588a123ccea80591438cd unix-2.7.3:9d41bcfbda690d764978c850d815017e xhtml-3000.2.2.1:c2b9d7e7a1bb227a9ebc7344ae3f6af2
Got:      Cabal-3.8.1.0:ed264dfad51755add5ad1550cefc7305 Cabal-syntax-3.8.1.0:11937df3ce969a94a33e89d0ba965dbe array-0.5.4.0:41bd88e1446deebe13fe286fbd046e2f base-4.17.2.1:f4d022627de1581765f39b0c2ad71cc2 binary-0.8.9.1:946a6cd8d0e6ebf36dd8bfceb47ad345 bytestring-0.11.5.3:a56dda3d5aab2a1e83b83fccb62fdea8 containers-0.6.7:f936e4da14408ab8dc11ca33468e91f8 deepseq-1.4.8.0:24cb6772eecf6f899a035fdce71ae195 directory-1.3.7.1:51461b8d852b24c1046ec72981f9e81f exceptions-0.10.5:a3c9d003b54ff36840d118d5810824ac filepath-1.4.2.2:111cdc817f86d32fec10d4d7b857e516 ghc-9.4.8:fbd3a30ae4708d5e9be083deb2efb560 ghc-bignum-1.3:a01c7de8f9ebbcc26fa13f4de49cd9f8 ghc-boot-9.4.8:f297069f89ed2cc59cc83dc079f69c79 ghc-boot-th-9.4.8:8a0c756ad78fa20c3a0e97fc1da48798 ghc-compact-0.1.0.0:5f2639ff33c3e14dd4e7ec29575a05b6 ghc-heap-9.4.8:7be5fab155258065b609b65d383366bb ghc-prim-0.9.1:ffde7061cf7182b2d3ec5d68c5c91fdb ghci-9.4.8:7c68069bd8138fcf5b4cb838e8d273c1 haskeline-0.8.2:947715e05372203385efe7c9eeddd798 hpc-0.6.1.0:8e530db3ae1badf54b006083dd2c261f integer-gmp-1.1:e71963e48407810a53e9323cf1b2d9fc libiserv-9.4.8:0db636c5ea8006cd60b4256834e2d610 mtl-2.2.2:e360d4baab21de5d0e6716d01fb48606 parsec-3.1.16.1:0c889a9c907717d0c0ddf464115dbc93 pretty-1.1.3.6:431df84361ffc7a6da4dddf4636b7e25 process-1.6.18.0:5df50172ffefee5d20f92d3f6f8c6b33 rts-1.0.2: stm-2.5.1.0:c47763c9c60a781a50a6f52175dbdc63 system-cxx-std-lib-1.0:00000000000000000000000000000000 template-haskell-2.19.0.0:c7020a3b4fcdf8b13d08b53ab80c87ff terminfo-0.4.1.5:d35174ed0e58934db2cdd6c529096669 text-2.0.2:176dddc9ce896cb54bf1ca9a3737a966 time-1.12.2:9f2ea07607e17c6ee857ccc49d48cd9d transformers-0.5.6.2:6263a3b644b588a123ccea80591438cd unix-2.7.3:9d41bcfbda690d764978c850d815017e xhtml-3000.2.2.1:c2b9d7e7a1bb227a9ebc7344ae3f6af2
Content-Length: 203

{"jsonrpc":"2.0", "method":"window/showMessage", "params": {"type": 1, "message": "Couldn't find a working/matching GHC installation. Consider installing ghc-9.4.8 via ghcup or build HLS from source."}}%                                                                                                                                                 
ocapn-suite on  handoffs [$!?] via λ lts-21.25 via ❄️  impure (nix-shell-env) took 7s
-31%03:48δ stack exec ghc -- --print-libdir
/nix/store/psds2pz1qhlr4z8qcahqii6kq1xsawb8-ghc-9.4.8/lib/ghc-9.4.8

ocapn-suite on  handoffs [$!?] via λ lts-21.25 via ❄️  impure (nix-shell-env)
-31%03:49δ ghc -- --print-libdir
/nix/store/psds2pz1qhlr4z8qcahqii6kq1xsawb8-ghc-9.4.8/lib/ghc-9.4.8
cab404 commented 9 months ago

I am using pre-built libraries from releases, adding gmp and ncurses with LD_LIBRARY_PATH.

system-ghc: true
nix:
  pure: false

in stack.yaml

fendor commented 9 months ago

@cab404 Your setup seems rather non-standard, and I am not surprised this trips up HLS.

If you use the system-ghc and pre-built HLS binaries from ghcup, make sure you have also followed https://www.haskell.org/ghcup/guide/#stack-integration

However, if you are using nixos, I recommend following the nixos philosophy and let it install ghc, hls and the other dependencies. Then let stack build the haskell packages using these tools. I think that should work more naturally, and maybe even a little bit easier if you use cabal.

fendor commented 5 months ago

Closing as nixos and ghcup are not expected to work well together. At least, I don't expect it.