haskell-ide-engine icon indicating copy to clipboard operation
haskell-ide-engine copied to clipboard

HIE errors on startup

Open LeanderK opened this issue 4 years ago • 11 comments

This is the log:

2020-01-03 17:55:33.948008 [ThreadId 4] - run entered for hie-wrapper(hie-wrapper) Version 1.0.0.0, Git revision 704ed3c982ce350f6aafbf4854e91da1e2a1d1c2 (dirty) (3528 commits) x86_64 ghc-8.6.5
2020-01-03 17:55:33.968581 [ThreadId 4] - Current directory:/Users/LeanderK/Documents/Haskell/hasktorch-comcat
2020-01-03 17:55:33.969844 [ThreadId 4] - Operating system:darwin
2020-01-03 17:55:34.069305 [ThreadId 4] - Cabal-Helper dirs: ["/Users/LeanderK/Documents/Haskell/hasktorch-comcat","/Users/LeanderK/Documents/Haskell/hasktorch-comcat/File.hs"]
2020-01-03 17:55:40.320621 [ThreadId 4] - Cradle directory:/Users/LeanderK/Documents/Haskell/hasktorch-comcat
2020-01-03 17:55:40.322384 [ThreadId 4] - Use Stack GHC
2020-01-03 17:55:40.973545 [ThreadId 4] - Project GHC version:8.6.5
2020-01-03 17:55:40.974105 [ThreadId 4] - hie exe candidates :["hie-8.6.5","hie-8.6","hie"]
2020-01-03 17:55:40.976355 [ThreadId 4] - found hie exe at:/Users/LeanderK/.local/bin/hie-8.6.5
2020-01-03 17:55:40.97713 [ThreadId 4] - args:["--lsp"]
2020-01-03 17:55:40.977523 [ThreadId 4] - launching ....



2020-01-03 17:55:41.12167 [ThreadId 4] - Run entered for HIE(hie-8.6.5) Version 1.0.0.0, Git revision 704ed3c982ce350f6aafbf4854e91da1e2a1d1c2 (dirty) (3528 commits) x86_64 ghc-8.6.5
2020-01-03 17:55:41.128316 [ThreadId 4] - Current directory:/Users/LeanderK/Documents/Haskell/hasktorch-comcat
2020-01-03 17:55:41.128448 [ThreadId 4] - args:["--lsp"]
2020-01-03 17:55:42.217548 [ThreadId 4] - Cabal-Helper dirs: ["/Users/LeanderK/Documents/Haskell/hasktorch-comcat","/Users/LeanderK/Documents/Haskell/hasktorch-comcat/File.hs"]
2020-01-03 17:55:45.902927 [ThreadId 4] - Use Stack GHC
2020-01-03 17:55:46.755292 [ThreadId 31] - Use Stack GHC
Using hie version: Version 1.0.0.0, Git revision 704ed3c982ce350f6aafbf4854e91da1e2a1d1c2 (dirty) (3528 commits) x86_64 ghc-8.6.5
Using hoogle db at: /Users/LeanderK/.hoogle/default-haskell-5.0.17.hoo
2020-01-03 17:55:47.509161 [ThreadId 37] - New cradle: /Users/LeanderK/Documents/Haskell/hasktorch-comcat/src/LibHaskComcat.hs
2020-01-03 17:55:47.513706 [ThreadId 37] - Cabal-Helper dirs: ["/Users/LeanderK/Documents/Haskell/hasktorch-comcat","/Users/LeanderK/Documents/Haskell/hasktorch-comcat/src/LibHaskComcat.hs"]
2020-01-03 17:55:50.238888 [ThreadId 37] - Found cradle: Cradle {cradleRootDir = "/Users/LeanderK/Documents/Haskell/hasktorch-comcat", cradleOptsProg = CradleAction: Cabal-Helper-Stack}
hasktorch-0.2.0.0: unregistering (local file changes: /Users/LeanderK/.stack/snapshots/x86_64-osx/5aec64b20ecf8cf33e0eb72f42c2084efb78fa3c898d1f2d32a00...)
hasktorch-comcat-0.1.0.0: unregistering (missing dependencies: hasktorch)
hasktorch       > configure (lib)
hasktorch       > Configuring hasktorch-0.2.0.0...
hasktorch       > build (lib)
hasktorch       > Preprocessing library for hasktorch-0.2.0.0..
hasktorch       > Building library for hasktorch-0.2.0.0..
hasktorch       > copy/register
hasktorch       > Installing library in /Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/hasktorch-0.2.0.0-J7gmn6ENwry3iNUclTAeCb
hasktorch       > Registering library for hasktorch-0.2.0.0..
hasktorch-comcat> configure (lib + exe)
Configuring hasktorch-comcat-0.1.0.0...
Completed 2 action(s).
hie-8.6.5: 
lookupSymbol failed in relocateSection (relocate external)
/Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/libtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0/libHSlibtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0.a: unknown symbol `__ZN3c1010Dispatcher10findSchemaERKNS_12OperatorNameE'
hie-8.6.5: 
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/libtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0/libHSlibtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0.a: unknown symbol `__ZN3c1019UndefinedTensorImpl10_singletonE'
hie-8.6.5: 
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/libtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0/libHSlibtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0.a: unknown symbol `__ZN3c1019UndefinedTensorImpl10_singletonE'
GHC runtime linker: fatal error: I found a duplicate definition for symbol
   __ZN3c1013intrusive_ptrINS_10TensorImplENS_19UndefinedTensorImplEE7retain_Ev
whilst processing object file
   /Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/libtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0/libHSlibtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0.a
The symbol was previously defined in
   /Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/libtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0/libHSlibtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0.a(Native.o)
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.
hie-8.6.5: 
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/lib/x86_64-osx-ghc-8.6.5/libtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0/libHSlibtorch-ffi-1.3.0.0-3VEeYCkllchEBgLlVLOxv0.a: unknown symbol `__ZN3c1019UndefinedTensorImpl10_singletonE'
2020-01-03 17:56:13.800489 [ThreadId 63] - Ghc error on cradle initialisation: "unable to load package `libtorch-ffi-1.3.0.0'"
2020-01-03 17:56:13.837999 [ThreadId 37] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "\"unable to load package `libtorch-ffi-1.3.0.0'\"", ideInfo = Null} with mid: Nothing
2020-01-03 17:56:13.839307 [ThreadId 37] - New cradle: /Users/LeanderK/Documents/Haskell/hasktorch-comcat/src/LibHaskComcat.hs
2020-01-03 17:56:13.842853 [ThreadId 37] - Cabal-Helper dirs: ["/Users/LeanderK/Documents/Haskell/hasktorch-comcat","/Users/LeanderK/Documents/Haskell/hasktorch-comcat/src/LibHaskComcat.hs"]
2020-01-03 17:56:17.50854 [ThreadId 37] - Found cradle: Cradle {cradleRootDir = "/Users/LeanderK/Documents/Haskell/hasktorch-comcat", cradleOptsProg = CradleAction: Cabal-Helper-Stack}
2020-01-03 17:56:19.647879 [ThreadId 143] - Ghc error on cradle initialisation: "panic! (the 'impossible' happened)\n  (GHC version 8.6.5 for x86_64-apple-darwin):\n\tDynamic linker not initialised\n\nPlease report this as a GHC bug:  http://www.haskell.org/ghc/reportabug\n"
2020-01-03 17:56:19.648594 [ThreadId 37] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "\"panic! (the 'impossible' happened)\\n  (GHC version 8.6.5 for x86_64-apple-darwin):\\n\\tDynamic linker not initialised\\n\\nPlease report this as a GHC bug:  http://www.haskell.org/ghc/reportabug\\n\"", ideInfo = Null} with mid: Nothing

The setup is quite complex, it's a project that depends on hasktorch. Create a new stack project with the hasktorch-project on the top-level as a git-submodule (git submodule add here-hasktorch-link), cd into hasktorch and follow the setup-instructions for hasktorch. Then add this as the top-level stack.yaml .

# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/

# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-14.19

# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
#   subdirs:
#   - auto-update
#   - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
#   commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#

extra-include-dirs:
    - hasktorch/deps/libtorch/include/torch/csrc/api/include
    - hasktorch/deps/libtorch/include

extra-lib-dirs:
    - hasktorch/deps/libtorch/lib
    - hasktorch/deps/mklml/lib

extra-deps:
    - categories-1.0.7@sha256:e707f8ac06eac755cb508aa67de64ab2e33ce1c54aebb6f43f64c615aa5234f6,1636
    - template-0.2.0.10@sha256:f822de4d34c45bc84b33a61bc112c15fedee6fa6dc414c62b10456395a868f85
    - inline-c-0.9.0.0
    - inline-c-cpp-0.4.0.0
    - ../hasktorch/codegen
    - ../hasktorch/libtorch-ffi
    - ../hasktorch/hasktorch

# Override default flag values for local packages and extra-deps
# flags: {}

# Extra package databases containing global packages
# extra-package-dbs: []

# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.1"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor

EDIT: one also needs to depend on:

dependencies:
- hasktorch
- libtorch-ffi

in package.yaml

LeanderK avatar Jan 03 '20 17:01 LeanderK

btw stack build works fine

LeanderK avatar Jan 03 '20 17:01 LeanderK

Can you try what happens if you add a custom hie.yaml? I dont know what your project looks like in general, so I just guess how it should look like:

cradle:
  stack:
    component: "project:lib"

Where "project:lib" is the library component of your project. EDIT: It may be named differently, you can find the library name with stack ide targets

fendor avatar Jan 03 '20 17:01 fendor

I just unregistered the libtorch-ffi package and recompiled it without success.

My project essentially looks like:

app/*
src/*
test/*
hasktorch/ (<- git submodule of the hasktorch project)
package.yaml (<- nothing special besides the dependencies mentioned above)
stack.yaml (<- copied from above)

using the hie.yaml with the stack ide targets i just get repeating errors of:

2020-01-03 18:21:37.023204 [ThreadId 35] - Found cradle: Cradle {cradleRootDir = "/Users/LeanderK/Documents/Haskell/hasktorch-comcat", cradleOptsProg = CradleAction: stack}
2020-01-03 18:21:38.588374 [ThreadId 254] - hasktorch-comcat> initial-build-steps (lib + exe)
2020-01-03 18:21:39.101826 [ThreadId 254] - Configuring GHCi with the following packages: hasktorch-comcat
2020-01-03 18:21:40.008604 [ThreadId 262] - /Users/LeanderK/Documents/Haskell/hasktorch-comcat/.stack-work/install/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/pkgdb:/Users/LeanderK/.stack/snapshots/x86_64-osx/939c413ab4a7d2343bb3a9b2ece27ffbd63771fd22078232752ce434eb022688/8.6.5/pkgdb:/Users/LeanderK/.stack/programs/x86_64-osx/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
2020-01-03 18:21:40.059488 [ThreadId 250] - Ghc error on cradle initialisation: "panic! (the 'impossible' happened)\n  (GHC version 8.6.5 for x86_64-apple-darwin):\n\tDynamic linker not initialised\n\nPlease report this as a GHC bug:  http://www.haskell.org/ghc/reportabug\n"
2020-01-03 18:21:40.059688 [ThreadId 35] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "\"panic! (the 'impossible' happened)\\n  (GHC version 8.6.5 for x86_64-apple-darwin):\\n\\tDynamic linker not initialised\\n\\nPlease report this as a GHC bug:  http://www.haskell.org/ghc/reportabug\\n\"", ideInfo = Null} with mid: Nothing

LeanderK avatar Jan 03 '20 17:01 LeanderK

Does hie work on trivial projects for you?

fendor avatar Jan 03 '20 17:01 fendor

@fendor hmmm....no, it doesn't. But it did a few days ago, so there must be something going on (upgraded HIE). I'll investigate.

LeanderK avatar Jan 03 '20 18:01 LeanderK

@fendor I get similar errors on other or completely newly clones projects:

Configuring concat-redux-0.1.0.0...
hie-8.6.5: ^^ Could not load '_concatzmreduxzm0zi1zi0zi0zm21HUV9SKq6C6WOV8oQEGnT_Lib_plugin_closure', dependency unresolved. See top entry above.

2020-01-03 19:58:28.816396 [ThreadId 60] - Ghc error on cradle initialisation: "\nByteCodeLink.lookupCE\nDuring interactive linking, GHCi couldn't find the following symbol:\n  concatzmreduxzm0zi1zi0zi0zm21HUV9SKq6C6WOV8oQEGnT_Lib_plugin_closure\nThis may be due to you not asking GHCi to load extra object files,\narchives or DLLs needed by your current session.  Restart GHCi, specifying\nthe missing library using the -L/path/to/object/dir and -lmissinglibname\nflags, or simply by naming the relevant files on the GHCi command line.\nAlternatively, this link failure might indicate a bug in GHCi.\nIf you suspect the latter, please send a bug report to:\n  [email protected]\n"
2020-01-03 19:58:28.816654 [ThreadId 35] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "\"\\nByteCodeLink.lookupCE\\nDuring interactive linking, GHCi couldn't find the following symbol:\\n  concatzmreduxzm0zi1zi0zi0zm21HUV9SKq6C6WOV8oQEGnT_Lib_plugin_closure\\nThis may be due to you not asking GHCi to load extra object files,\\narchives or DLLs needed by your current session.  Restart GHCi, specifying\\nthe missing library using the -L/path/to/object/dir and -lmissinglibname\\nflags, or simply by naming the relevant files on the GHCi command line.\\nAlternatively, this link failure might indicate a bug in GHCi.\\nIf you suspect the latter, please send a bug report to:\\n  [email protected]\\n\"", ideInfo = Null} with mid: Nothing
2020-01-03 19:58:28.817314 [ThreadId 35] - New cradle: /Users/LeanderK/Downloads/compiling-to-categories-redux/src/Lib.hs
2020-01-03 19:58:28.833607 [ThreadId 35] - Cabal-Helper dirs: ["/Users/LeanderK/Downloads/compiling-to-categories-redux","/Users/LeanderK/Downloads/compiling-to-categories-redux/src/Lib.hs"]
2020-01-03 19:58:31.201309 [ThreadId 35] - Found cradle: Cradle {cradleRootDir = "/Users/LeanderK/Downloads/compiling-to-categories-redux", cradleOptsProg = CradleAction: Cabal-Helper-Stack}
2020-01-03 19:58:32.41782 [ThreadId 29] - Scheduler thread exited unexpectedly: expectJust getLinkDeps
CallStack (from HasCallStack):
  error, called at compiler/utils/Maybes.hs:55:27 in ghc:Maybes
  expectJust, called at compiler/ghci/Linker.hs:719:28 in ghc:Linker

EDIT: it sometimes just works, at least on the newly cloned project. not sure what's happening to be honest. I will reinstall HIE over night

LeanderK avatar Jan 03 '20 18:01 LeanderK

I got the same error:

Dynamic linker not initialised

when using hie as the engine for vim and coc.nvim.

The problem was solved by making sure the resolver in my stack.yaml at the top level of the project directory matched that in ~/haskell-ide-engine/install/shake.yaml

i.e.

resolver: lts-14.11 # GHC 8.6.5

Did you install hie using:

stack install.hs hie or did you choose a particular ghc version?

Montmorency avatar Feb 17 '20 22:02 Montmorency

i chose a particular ghc version via stack ./install.hs hie-8.6.5

LeanderK avatar Feb 18 '20 09:02 LeanderK

I'm pretty sure thats what I did (we are both use x86-64 apple darwin archs):

stack ./install.hs hie-8.6.5
stack ./install.hs data

You can double check that the --version on hie-wrapper is correct and use stack path to make sure everything is using the right version of ghc.

I notice in the Hask torch project you have the resolver at

resolver: lts-14.19

You could try rolling back to resolver: lts-14.11 # GHC 8.6.5

And reinstalling haskell-ide-engine?

Montmorency avatar Feb 20 '20 12:02 Montmorency

resolver: lts-14.19

You could try rolling back to resolver: lts-14.11 # GHC 8.6.5

This actually solved the problem! Maybe HIE could warn when this case occurs?

LeanderK avatar Feb 27 '20 20:02 LeanderK

Same happened to me with s fresh started project. Downgraded to lts-14.11 from lts-15 and it worked!

Glitches avatar May 16 '20 14:05 Glitches