Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Error in emacs: can't load .so/.DLL for libm.so.6 due to GLIBC_2.29 #32

Closed
jasagredo opened this issue Nov 13, 2019 · 36 comments
Closed

Comments

@jasagredo
Copy link

After some issues with the non-nix build I decided to move to the nix build. When starting a new stack project I am able to use hie perfectly fine as seen here:
image

But I have a specific project in which I can't make this work and it is related to the nix build. When I open the project I get these messages:

LSP :: Connected to [hie:29825 status:starting].
LSP :: hie:29825 initialized successfully
LSP :: Got error while processing diagnostics: <command line>: can't load .so/.DLL for: /home/javier/.stack/snapshots/x86_64-linux-tinfo6/d99516f3f2c0b41f0af91917226f0e96f8e7d0f17cb031a0a718c3f53ea53f44/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSerf-2.0.0.0-ExhHoenPosmHlOroBQQced-ghc8.6.5.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /home/javier/.stack/snapshots/x86_64-linux-tinfo6/d99516f3f2c0b41f0af91917226f0e96f8e7d0f17cb031a0a718c3f53ea53f44/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSerf-2.0.0.0-ExhHoenPosmHlOroBQQced-ghc8.6.5.so))

As seen in the error message, libHSerf requires GLIBC_2.29 and the libm that is being retrieved is the one inside the nix store which is glibc-2.27.

I'm using cabal-install-2.4.1.0 because there seems to be some issues with cabal-install-3.0.0.0.

 javier@Javier-Workstation  ~  which cabal
/home/javier/.nix-profile/bin/cabal
 javier@Javier-Workstation  ~  which stack      
/home/javier/.nix-profile/bin/stack
 javier@Javier-Workstation  ~  which hie-wrapper
/home/javier/.nix-profile/bin/hie-wrapper
javier@Javier-Workstation  ~/.nix-profile/bin  ls -la | grep -E "(cabal|hie|stack)"
lrwxrwxrwx 1 javier javier   75 ene  1  1970 cabal -> /nix/store/ld4pvikswds1qfi3b7fy85skfc336r7j-cabal-install-2.4.1.0/bin/cabal
lrwxrwxrwx 1 javier javier   79 ene  1  1970 hie -> /nix/store/cqjylkc7yi8i1fkny2cb1v81rqx9gy2a-haskell-ide-engine-combined/bin/hie
lrwxrwxrwx 1 javier javier   85 ene  1  1970 hie-8.6.5 -> /nix/store/cqjylkc7yi8i1fkny2cb1v81rqx9gy2a-haskell-ide-engine-combined/bin/hie-8.6.5
lrwxrwxrwx 1 javier javier   87 ene  1  1970 hie-wrapper -> /nix/store/cqjylkc7yi8i1fkny2cb1v81rqx9gy2a-haskell-ide-engine-combined/bin/hie-wrapper
lrwxrwxrwx 1 javier javier   67 ene  1  1970 stack -> /nix/store/zjrl2mhy6bc3jfiz7wzhlbamhy4s7syl-stack-2.1.3.1/bin/stack
@jasagredo
Copy link
Author

Also after that error sometimes this other error also shows up:

LSP :: Got error while processing diagnostics: GHC panic! (the 'impossible' happened)
  ghc-mod version 5.9.0.0
  GHC library version 8.6.5 for x86_64-unknown-linux:
       Dynamic linker not initialised

Please report this as a bug: https://github.com/kazu-yamamoto/ghc-mod/issues

I believe it is related to the first error failing on finding the appropriate glibc libraries.

@infinisil
Copy link
Owner

Have you tried clearing ~/.stack? I feel like stack might have linked to a previous glibc in your store, but a nix garbage collection has happened since then. Forcing stack to build its products anew might solve this.

@tek
Copy link

tek commented Nov 14, 2019

I switched to nix-built hie from a system with glibc 2.29, with nix using 2.27. The libs built into ~/.stack were linked against the system glibc, so clearing that was the solution.

@andys8
Copy link

andys8 commented Jan 13, 2020

I think I'm also running into this. Removing ~/.stack doesn't and running stack build leads to the same error.

    "message": "Got error while processing diagnostics: <command line>: can't load .so/.DLL for: /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/46266fb5df1efd8b1231a788fa7ac46be7aa9e95e09bd429cb892cdcfc5d2f2f/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/46266fb5df1efd8b1231a788fa7ac46be7aa9e95e09bd429cb892cdcfc5d2f2f/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so))"

(source ghcmod)

System

Vim 8.1
Manjaro 18.1.5 Juhraya
all-hies 0.14.0.0

$ which cabal
/home/andreas/.nix-profile/bin/cabal
$ which stack
/home/andreas/.nix-profile/bin/stack
$ which hie-wrapper
/home/andreas/.nix-profile/bin/hie-wrapper

$ /n/s/m/bin $ ls -la | grep -E "(cabal|hie|stack)"
lrwxrwxrwx 1 andreas andreas   75  1. Jan 1970  cabal -> /nix/store/f01lnpkwcg5cfj7lxf2riy0h10y0f925-cabal-install-3.0.0.0/bin/cabal
lrwxrwxrwx 1 andreas andreas   74  1. Jan 1970  cabal2nix -> /nix/store/fxp0gsisy1a47n6q48cs2s89p97f17fz-cabal2nix-2.14.4/bin/cabal2nix
lrwxrwxrwx 1 andreas andreas   79  1. Jan 1970  hie -> /nix/store/f7qnh7k2rrsvxc0l4qc145jksqa37f6l-haskell-ide-engine-combined/bin/hie
lrwxrwxrwx 1 andreas andreas   85  1. Jan 1970  hie-8.6.5 -> /nix/store/f7qnh7k2rrsvxc0l4qc145jksqa37f6l-haskell-ide-engine-combined/bin/hie-8.6.5
lrwxrwxrwx 1 andreas andreas   87  1. Jan 1970  hie-wrapper -> /nix/store/f7qnh7k2rrsvxc0l4qc145jksqa37f6l-haskell-ide-engine-combined/bin/hie-wrapper
lrwxrwxrwx 1 andreas andreas   67  1. Jan 1970  stack -> /nix/store/4g7z4w5wcrnnjyjib6ms21jcj5qs99id-stack-2.1.3.1/bin/stack

@tek
Copy link

tek commented Jan 13, 2020

@andys8 in ldd /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/46266fb5df1efd8b1231a788fa7ac46be7aa9e95e09bd429cb892cdcfc5d2f2f/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so, to which libm/glibc does it point?

@andys8
Copy link

andys8 commented Jan 14, 2020

	linux-vdso.so.1 (0x00007ffd4d39a000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007f6b93b84000)
	libHSprimitive-0.6.4.0-ILgywxtLpvnAOlEISPpP5b-ghc8.6.5.so => /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/46266fb5df1efd8b1231a788fa7ac46be7aa9e95e09bd429cb892cdcfc5d2f2f/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSprimitive-0.6.4.0-ILgywxtLpvnAOlEISPpP5b-ghc8.6.5.so (0x00007f6b93ab5000)
	libHStransformers-0.5.6.2-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/transformers-0.5.6.2/libHStransformers-0.5.6.2-ghc8.6.5.so (0x00007f6b9396e000)
	libHSinteger-logarithms-1.0.3-4fjS4bKV0939VXcQKK2I7B-ghc8.6.5.so => /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/46266fb5df1efd8b1231a788fa7ac46be7aa9e95e09bd429cb892cdcfc5d2f2f/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSinteger-logarithms-1.0.3-4fjS4bKV0939VXcQKK2I7B-ghc8.6.5.so (0x00007f6b9395a000)
	libHShashable-1.2.7.0-2SI038axTEd7AEZJ275kpi-ghc8.6.5.so => /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/46266fb5df1efd8b1231a788fa7ac46be7aa9e95e09bd429cb892cdcfc5d2f2f/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHShashable-1.2.7.0-2SI038axTEd7AEZJ275kpi-ghc8.6.5.so (0x00007f6b93921000)
	libHStext-1.2.3.1-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/text-1.2.3.1/libHStext-1.2.3.1-ghc8.6.5.so (0x00007f6b936eb000)
	libHSbinary-0.8.6.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/binary-0.8.6.0/libHSbinary-0.8.6.0-ghc8.6.5.so (0x00007f6b9364a000)
	libHScontainers-0.6.0.1-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/containers-0.6.0.1/libHScontainers-0.6.0.1-ghc8.6.5.so (0x00007f6b932e2000)
	libHSbytestring-0.10.8.2-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2/libHSbytestring-0.10.8.2-ghc8.6.5.so (0x00007f6b931f8000)
	libHSdeepseq-1.4.4.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/deepseq-1.4.4.0/libHSdeepseq-1.4.4.0-ghc8.6.5.so (0x00007f6b931de000)
	libHSarray-0.5.3.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/array-0.5.3.0/libHSarray-0.5.3.0-ghc8.6.5.so (0x00007f6b9315c000)
	libHSbase-4.12.0.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/base-4.12.0.0/libHSbase-4.12.0.0-ghc8.6.5.so (0x00007f6b927d7000)
	libHSinteger-gmp-1.0.2.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0/libHSinteger-gmp-1.0.2.0-ghc8.6.5.so (0x00007f6b92795000)
	libHSghc-prim-0.5.3-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3/libHSghc-prim-0.5.3-ghc8.6.5.so (0x00007f6b92305000)
	libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007f6b92272000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f6b920ab000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007f6b93d58000)

@andys8
Copy link

andys8 commented Jan 14, 2020

I tried to use nix, but not use the all-hies cache and 0.14.0.0. Probably some beginner mistakes? ;)

	linux-vdso.so.1 (0x00007fffdcd15000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007fab14246000)
	libHSprimitive-0.6.4.0-ILgywxtLpvnAOlEISPpP5b-ghc8.6.5.so => /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSprimitive-0.6.4.0-ILgywxtLpvnAOlEISPpP5b-ghc8.6.5.so (0x00007fab14177000)
	libHStransformers-0.5.6.2-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/transformers-0.5.6.2/libHStransformers-0.5.6.2-ghc8.6.5.so (0x00007fab14030000)
	libHSinteger-logarithms-1.0.3-4fjS4bKV0939VXcQKK2I7B-ghc8.6.5.so => /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSinteger-logarithms-1.0.3-4fjS4bKV0939VXcQKK2I7B-ghc8.6.5.so (0x00007fab1401c000)
	libHShashable-1.2.7.0-2SI038axTEd7AEZJ275kpi-ghc8.6.5.so => /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHShashable-1.2.7.0-2SI038axTEd7AEZJ275kpi-ghc8.6.5.so (0x00007fab13fe3000)
	libHStext-1.2.3.1-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/text-1.2.3.1/libHStext-1.2.3.1-ghc8.6.5.so (0x00007fab13dad000)
	libHSbinary-0.8.6.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/binary-0.8.6.0/libHSbinary-0.8.6.0-ghc8.6.5.so (0x00007fab13d0c000)
	libHScontainers-0.6.0.1-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/containers-0.6.0.1/libHScontainers-0.6.0.1-ghc8.6.5.so (0x00007fab139a4000)
	libHSbytestring-0.10.8.2-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2/libHSbytestring-0.10.8.2-ghc8.6.5.so (0x00007fab138ba000)
	libHSdeepseq-1.4.4.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/deepseq-1.4.4.0/libHSdeepseq-1.4.4.0-ghc8.6.5.so (0x00007fab138a0000)
	libHSarray-0.5.3.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/array-0.5.3.0/libHSarray-0.5.3.0-ghc8.6.5.so (0x00007fab1381e000)
	libHSbase-4.12.0.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/base-4.12.0.0/libHSbase-4.12.0.0-ghc8.6.5.so (0x00007fab12e99000)
	libHSinteger-gmp-1.0.2.0-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0/libHSinteger-gmp-1.0.2.0-ghc8.6.5.so (0x00007fab12e57000)
	libHSghc-prim-0.5.3-ghc8.6.5.so => /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3/libHSghc-prim-0.5.3-ghc8.6.5.so (0x00007fab129c7000)
	libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007fab12934000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007fab1276d000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007fab1441a000)
[Trace - 4:24:57 PM] Received notification 'window/showMessage'.
Params: {
    "type": 1,
    "message": "Got error while processing diagnostics: <command line>: can't load .so/.DLL for: /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so))"
}


[Trace - 4:24:57 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/andreas/dev/<proj>/app/Main.hs",
    "diagnostics": [
        {
            "severity": 1,
            "range": {
                "start": {
                    "line": 0,
                    "character": 0
                },
                "end": {
                    "line": 1,
                    "character": 0
                }
            },
            "source": "ghcmod",
            "message": "<command line>: can't load .so/.DLL for: /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /home/andreas/.stack/snapshots/x86_64-linux-tinfo6/2cb45d0f6c8f55c359ea8858720670ea7f0d4e1798605627aff54d7553aab8d1/8.6.5/lib/x86_64-linux-ghc-8.6.5/libHSscientific-0.3.6.2-BboXwnuKby4BtCVtfss4TP-ghc8.6.5.so))\n"
        }
    ]
}

@tek
Copy link

tek commented Jan 14, 2020

your stack linked against /usr/lib/libm.so, while hie is using glibc from nix. you need to build stack with nix.

andys8 added a commit to andys8/dotfiles that referenced this issue Jan 14, 2020
@andys8
Copy link

andys8 commented Jan 14, 2020

@tek

Hmm. I need to build stack with nix? I'm installing it with nix, but I think caches are used.

$ which -a stack ghc cabal
/home/andreas/.nix-profile/bin/stack
/home/andreas/.nix-profile/bin/ghc
/home/andreas/.nix-profile/bin/cabal

@tek
Copy link

tek commented Jan 14, 2020

well, something in the toolchain has got to be linking to the operating system's glibc. is there another stack or ghc in the system? maybe try removing that from the path, also check ldd $(which stack)

@andys8
Copy link

andys8 commented Jan 14, 2020

There is (currently) no other ghc or stack installed:

$ which -a hie-wrapper ghc stack cabal hlint
/home/andreas/.nix-profile/bin/hie-wrapper
/home/andreas/.nix-profile/bin/ghc
/home/andreas/.nix-profile/bin/stack
/home/andreas/.nix-profile/bin/cabal
/home/andreas/.nix-profile/bin/hlint
$ ldd (which stack)
	linux-vdso.so.1 (0x00007ffdef9fe000)
	libm.so.6 => /nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/libm.so.6 (0x00007f3156cdd000)
	libsqlite3.so.0 => /nix/store/cx2a04bg8339r039wqx6wqjblxwjbwg1-sqlite-3.28.0/lib/libsqlite3.so.0 (0x00007f3156bc5000)
	libpthread.so.0 => /nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/libpthread.so.0 (0x00007f3156ba4000)
	libz.so.1 => /nix/store/f8zs7mknva4rdx7zxr6j54y0igh3pras-zlib-1.2.11/lib/libz.so.1 (0x00007f3156b85000)
	librt.so.1 => /nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/librt.so.1 (0x00007f3156b7b000)
	libutil.so.1 => /nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/libutil.so.1 (0x00007f3156b74000)
	libdl.so.2 => /nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/libdl.so.2 (0x00007f3156b6f000)
	libgmp.so.10 => /nix/store/vqc2zncb0f1b945dq7j2pcyygfxmcf3v-gmp-6.1.2/lib/libgmp.so.10 (0x00007f3156ad9000)
	libffi.so.6 => /nix/store/i5b8dwcyh4kjmsp7ggffn5frq1ib5dd3-libffi-3.2.1/lib/libffi.so.6 (0x00007f3156acd000)
	libc.so.6 => /nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/libc.so.6 (0x00007f3156917000)
	/nix/store/kksyrix1bpklvgkmvngcv0q9nh8hn2fl-glibc-2.27/lib/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f3156e75000)

But when running stack build it'll download ghc-tinfo6. Could this cause the issue?

Downloaded ghc-tinfo6-8.6.5.
Unpacking GHC into /home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5.temp/

I'm pretty sure I'm doing at least something wrong or there is cached data not being deleted. I'll stick with installing haskell-ide-engine myself, which seems to work fine and will revisit the issue another time. Thanks for your help, @tek

@tek
Copy link

tek commented Jan 14, 2020

just to be safe, does your global ~/.stack/config.yaml have nix: enable: true?

@expipiplus1
Copy link
Contributor

I have bumped into this because of the glibc update in nixpkgs.

hie from all-hies doesn't work when ghc is sourced from NixOS/nixpkgs@3846896084f but it does work when ghc is sourced from the parent commit NixOS/nixpkgs@fa744553290

@poscat0x04
Copy link

I'm experiencing this with a cabal project that uses ghc-8.6.5. cabal build works fine but ghc panics when being called by hie.

@expipiplus1
Copy link
Contributor

@poscat0x04 FWIW I've switched to ghc882 which seems to be running without issue .

@poscat0x04
Copy link

Yeah switching to ghc882 worked but a lot of binary caches were missing.

@poscat0x04
Copy link

This issue also affects ghcide-nix for some reason.

@infinisil
Copy link
Owner

I recently talked with @domenkozar regarding this. It seems that the glibc version for HIE and the one for the GHC in your environment have to match for it to work. The same goes for ghcide.

Looking at the glibc versions used for stable all-hies, they're

  • ghc842: glibc-2.27
  • ghc843: glibc-2.27
  • ghc844: glibc-2.27
  • ghc864: glibc-2.27
  • ghc865: glibc-2.27
  • ghc881: glibc-2.30
  • ghc882: glibc-2.30

So for now the best workaround should be to make sure the GHC you have uses the same glibc version. You should be able to check your GHC's glibc version with

$ ldd $(which ghc)
	linux-vdso.so.1 (0x00007fff0ad22000)
[...]
	libc.so.6 => /nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libc.so.6 (0x00007fc974dc8000)
	/nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/ld-linux-x86-64.so.2 => /nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib64/ld-linux-x86-64.so.2 (0x00007fc97bcea000)

or if ghc is a wrapper (not a dynamic executable), this should work:

$ strace -z -e file ghc 2>&1 | grep libc.so
openat(AT_FDCWD, "/nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

@andys8
Copy link

andys8 commented Mar 13, 2020

Thanks for the elaboration. Would it be possible to script this check into the mix expression itself, so it'll deny installation and say "your system would only work with ghc version x because your system's glibc version is y"? That'll be more than to expect but pretty nice :)

@infinisil
Copy link
Owner

I have to do some rewriting for switching to 1.2, see #52. This might enable a better way to deal with this.

@teto
Copy link

teto commented Mar 27, 2020

I am trying to do some haskell work and would love to get HIE in but I get this error (ghcide works fine but it lacks completion).
I wonder how I can fix this. It seems to me that I would need to recompile hie with an updated hash (let's say current nixos-unstable since I am on current nixos-unstable, using ghc865) for https://github.com/Infinisil/all-hies/blob/master/nixpkgsForGhc/ghc865 ?

due to the lockdown, I am at home with an 8 year old laptop and ~7Gb of free disk space, hence my question, I would like to make sure before trying anything.

@infinisil
Copy link
Owner

@teto Yeah I think that would work if you need ghc865 for glibc 2.30. Note that if you do this, you'll also have to add the correct hash for that nixpkgs rev in https://github.com/Infinisil/all-hies/tree/master/generated/stable/nixpkgsHashes.

@21it
Copy link

21it commented Mar 30, 2020

I have the same issue. As I understood, the solution for it - to not use cachix?

@teto
Copy link

teto commented Mar 30, 2020

you should run a ghc using the same glibc as hie. Each hie version uses a specific nixpkgs so:

@21it
Copy link

21it commented Mar 30, 2020

@teto could you help me, I'm using this derivation in my shell.nix
https://github.com/tim2CF/ultimate-haskell-ide/blob/master/default.nix

As far as I see, latest all-hies is used there
https://github.com/tim2CF/ultimate-haskell-ide/blob/master/default.nix#L19-L20
And ghc865
https://github.com/tim2CF/ultimate-haskell-ide/blob/master/default.nix#L67
And nixpkgs version is
https://github.com/tim2CF/ultimate-haskell-ide/blob/master/nixpkgs20.nix#L2

So I have to use other nixpkgs commit? If you solved this issue, could you please share nixpkgs commit where everything is working?

schmittlauch pushed a commit to schmittlauch/all-hies that referenced this issue Mar 31, 2020
@schmittlauch
Copy link

I just bumped hie-865 for ghc865 to build against glibc-2.30 by building against a recent nixpkgs commit from release-20.03.
Feel free to try it, building it takes a while though: https://github.com/schmittlauch/all-hies/tree/fixGhc865Glibc

@infinisil How do you usually compute the sha256sum of a nixpkgs revision? This probably requires removing/ ignoring the .git directory. I just took the "let-it-fail" approach, but maybe there's a better way.

schmittlauch added a commit to schmittlauch/all-hies that referenced this issue Mar 31, 2020
@infinisil
Copy link
Owner

@schmittlauch Usually that's done by the update script (see https://github.com/infinisil/all-hies#updating-this-repository, the calculation is done here), though the whole script takes quiet a while to run, probably not worth for just such a simple change.

@21it
Copy link

21it commented Mar 31, 2020

Btw, I found alternative workaround - just needed to downgrade my nixpkgs to 19.09-beta

@schmittlauch
Copy link

@tkachuk-labs Which nixpkgs where?
Also, why move backwards when you can also move forwards? ;)

@schmittlauch
Copy link

@infinisil So what do you think about rebuilding all relevant versions against a recent commit from release-20.03, once that is out of beta?
I'd volunteer at least for hie-865, not sure about other versions because I'd have to think about testing them.

@dansanduleac
Copy link

I recently talked with @domenkozar regarding this. It seems that the glibc version for HIE and the one for the GHC in your environment have to match for it to work. The same goes for ghcide.

So for now the best workaround should be to make sure the GHC you have uses the same glibc version. You should be able to check your GHC's glibc version with

I think the requirement is even stricter.

Regardless of what GHC is installed in my profile / visible through PATH, I suspect the stack nix tooling will install "the system GHC" based on your default <nixpkgs> and still use that (I use unstable).

Case in point, I have installed into my profile the exact ghc-8.6.5 that comes from hie:

$ nix-store -qR /nix/store/qwrwp6zrmw2slvfqzx5dl4wziq8jcjgh-haskell-ide-engine-ghc865-1.1 | grep ghc-8.6.5
/nix/store/xhmlg19v5kpnn0zz08zi6yxvcj0k0wmq-ghc-8.6.5-doc
/nix/store/m80snlingdn5qgnklzaixscsvw2gsamq-ghc-8.6.5

$ nix path-info $(which ghc)
/nix/store/m80snlingdn5qgnklzaixscsvw2gsamq-ghc-8.6.5

and you can see that ghc uses glibc 2.27:

strace -z -e file ghc 2>&1 | grep -e '-glibc-2\..*/libc.so'
openat(AT_FDCWD, "/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

~/.stack was cleared and ~/.stack/stack.yaml contains only:

nix:
  enable: true
  packages: [zlib.dev, zlib.out]

The zlib is thanks to commercialhaskell/stack#2130 (comment), without which stack build will fail to build zlib.

However, hie still breaks like so:

2020-04-08 21:38:09.7156885 [ThreadId 4] - run entered for hie-wrapper(hie) Version 1.1 x86_64 ghc-8.6.5
...

2020-04-08 21:40:04.3093698 [ThreadId 4] - Ghc error on cradle initialisation: "can't load .so/.DLL for: /nix/store/lr20kmjm5plq4v8z685ib1qbg13crkic-ghc-8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3/libHSghc-prim-0.5.3-ghc8.6.5.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /nix/store/lr20kmjm5plq4v8z685ib1qbg13crkic-ghc-8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3/libHSghc-prim-0.5.3-ghc8.6.5.so))"

As you can see, for some reason it's still trying to use the lr20kmjm5plq4v8z685ib1qbg13crkic-ghc-8.6.5 which comes with my current nix channel.

@infinisil
Copy link
Owner

@dansanduleac Check out https://docs.haskellstack.org/en/stable/nix_integration/#package-sources, which should allow you to set e.g.

nix:
  path: [nixpkgs=https://github.com/NixOS/nixpkgs/tarball/650a295621b27c4ebe0fa64a63fd25323e64deb3]

So Stack takes the GHC version from there instead of the default <nixpkgs>. The nixpkgs commit there is from https://github.com/Infinisil/all-hies/blob/master/nixpkgsForGhc/ghc865

@steshaw
Copy link
Contributor

steshaw commented Jun 23, 2020

@infinisil, I've upgraded from HIE 1.1 to HIE 1.4 using the haskell.nix branch. I'm using Stack on Nix and I can't find the appropriate commit to pin my GHC 8.6.5 to (as per your previous comment). Using 650a295621b27c4ebe0fa64a63fd25323e64deb3results in an error loading for libpthread.so.0:

LSP :: "can't load .so/.DLL for: /nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libpthread.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/libpthread.so.0: undefined symbol: __libc_vfork, version GLIBC_PRIVATE)" [2 times]

I can't find https://github.com/Infinisil/all-hies/blob/master/nixpkgsForGhc/ghc865 on the haskell.nix branch.

@infinisil
Copy link
Owner

@steshaw The haskell.nix branch always uses a nixpkgs with glibc 2.30, so any recent nixpkgs will work (e.g. 20.03 or unstable)

@steshaw
Copy link
Contributor

steshaw commented Jun 24, 2020

Thanks, @infinisil. I used 0f5ce2fac0c726036ca69a5524c59a49e2973dd4 (from nixos-unstable) which works a treat. I had thought that the commit hash had to be precisely the same.

@infinisil
Copy link
Owner

This should now be fixed with the project revamp in #64, which forces a project-local Nix environment, in which the glibc version can be matched against the one GHC uses

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests