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

Statically linked Linux binaries cannot run interactive session #221

Closed
paweln1986 opened this issue Jul 23, 2020 · 48 comments
Closed

Statically linked Linux binaries cannot run interactive session #221

paweln1986 opened this issue Jul 23, 2020 · 48 comments
Assignees
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@paweln1986
Copy link

paweln1986 commented Jul 23, 2020

I encountered an issue using evaluate comment functionality with message unable to load package ghc-prim-0.5.3'`.
hls version - 0.2.1
stack version - 2.3.1

2020-07-23 10:55:21.112387789 [ThreadId 11208] - finish: runEvalCmd.getModSummary (took 0.00s)
haskell-language-server-0.2.1-linux-8.8.2: ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.2/lib/ghc-8.8.2/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
2020-07-23 10:55:21.15957216 [ThreadId 21] - Unexpected exception on request, please report!
Message: RequestMessage {_jsonrpc = "2.0", _id = IdInt 167, _method = WorkspaceExecuteCommand, _params = ExecuteCommandParams {_command = "695140:eval:evalCommand", _arguments = Just (List [Object (fromList [("module_",Object (fromList [("uri",String "file://***/Slot.hs")])),("editTarget",Object (fromList [("start",Object (fromList [("line",Number 7.0),("character",Number 0.0)])),("end",Object (fromList [("line",Number 7.0),("character",Number 0.0)]))])),("statements",Array [Array [String "unwords aaaa",Number 6.0]])])]), _workDoneToken = Nothing}}
Exception: haskell-language-server-0.2.1-linux-8.8.2: unable to load package `ghc-prim-0.5.3'
[Error - 10:55:21 AM] Request workspace/executeCommand failed.
  Message: haskell-language-server-0.2.1-linux-8.8.2: unable to load package `ghc-prim-0.5.3'
  Code: -32603

Am I missing something?

@paweln1986 paweln1986 changed the title unable to load package `ghc-prim-0.5.3' using eval feature unable to load package `ghc-prim-0.5.3' using evaluate comment feature Jul 23, 2020
@jneira jneira added component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jul 23, 2020
@pepeiborra
Copy link
Collaborator

Please attach the full log to see if it's something obvious.

@paweln1986
Copy link
Author

paweln1986 commented Jul 23, 2020

The full log from start of VisualCode + hls:

[client] run command: "/home/someUser/.config/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.2 --lsp"
[client] debug command: "/home/someUser/.config/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.2 --lsp -d -l hie-logs.log"
[client] server cwd: undefined
haskell-language-server version: 0.2.1.0 (GHC: 8.8.2) (PATH: /home/someUser/.config/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.2) (GIT hash: e8812c18d2be311c6b52545a0dc2b1408f8fa4b2)
Starting (haskell-language-server)LSP server...
  with arguments: Arguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsVersion = False, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "eval",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "stylish-haskell"]
  in directory: /home/someUser/project/haskell/simulator
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.00s
2020-07-23 11:33:16.78524586 [ThreadId 21] - Opened text document: file:///home/someUser/project/haskell/simulator/src/Layout/Slot.hs
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Base.hs:733:16 in unordered-containers-0.2.11.0-039aa212faca5a7496273cc439e0f9315ad99c657370bdaf5932fd93eae462e1:Data.HashMap.Base
  !, called at src/Development/IDE/Import/DependencyInformation.hs:107:40 in ghcide-0.2.0-inplace:Development.IDE.Import.DependencyInformation
2020-07-23 11:33:16.786462668 [ThreadId 63] - Consulting the cradle for "/home/someUser/project/haskell/simulator/src/Layout/Slot.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/someUser/project/haskell/simulator", cradleOptsProg = CradleAction: Stack}
[Error - 11:33:16 AM] haskell-lsp:configuration parse error. NotificationMessage {_jsonrpc = "2.0", _method = WorkspaceDidChangeConfiguration, _params = DidChangeConfigurationParams {_settings = Object (fromList [("haskell",Object (fromList [("logFile",String "hie-logs.log"),("hlintOn",Bool True),("formatOnImportOn",Bool True),("enable",Bool True),("indentationRules",Object (fromList [("enabled",Bool True)])),("liquidOn",Bool True),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "ormolu"),("trace",Object (fromList [("server",String "messages")]))]))])}} "key \"languageServerHaskell\" not found"
> simulator> configure (lib + exe)
> Configuring simulator-0.1.0.0...
> simulator> initial-build-steps (lib + exe)
> Configuring GHCi with the following packages: simulator
> /home/someUser/project/haskell/simulator/.stack-work/install/x86_64-linux-tinfo6/72bcf577c641dc9870d8476782df8c7ebf81ae232c4df4974259796aabcee719/8.8.2/pkgdb:/home/someUser/.stack/snapshots/x86_64-linux-tinfo6/72bcf577c641dc9870d8476782df8c7ebf81ae232c4df4974259796aabcee719/8.8.2/pkgdb:/home/someUser/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.2/lib/ghc-8.8.2/package.conf.d
2020-07-23 11:33:21.225546187 [ThreadId 63] - Using interface files cache dir: /home/someUser/.cache/ghcide/main-92ef7b6089c0518b8c07cd82c9748e52ecb4c467
2020-07-23 11:33:21.225860067 [ThreadId 63] - Making new HscEnv[main]
2020-07-23 11:33:21.353706517 [ThreadId 152] - Plugin.makeCodeLens (ideLogger)
2020-07-23 11:33:21.354022443 [ThreadId 144] - finish: CodeAction (took 0.00s)
2020-07-23 11:33:21.560536572 [ThreadId 221] - finish: codeLens (took 0.21s)
2020-07-23 11:33:21.560874209 [ThreadId 221] - finish: CodeAction (took 0.00s)
2020-07-23 11:33:22.19841128 [ThreadId 227] - finish: CodeAction:PackageExports (took 0.64s)
2020-07-23 11:33:30.889981117 [ThreadId 227] - finish: runEvalCmd.ghcSession (took 0.00s)
2020-07-23 11:33:30.890581774 [ThreadId 227] - finish: runEvalCmd.getModSummary (took 0.00s)
haskell-language-server-0.2.1-linux-8.8.2: /home/someUser/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.2/lib/ghc-8.8.2/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
2020-07-23 11:33:30.988301535 [ThreadId 21] - Unexpected exception on request, please report!
Message: RequestMessage {_jsonrpc = "2.0", _id = IdInt 5, _method = WorkspaceExecuteCommand, _params = ExecuteCommandParams {_command = "843996:eval:evalCommand", _arguments = Just (List [Object (fromList [("module_",Object (fromList [("uri",String "file:///home/someUser/project/haskell/simulator/src/Layout/Slot.hs")])),("editTarget",Object (fromList [("start",Object (fromList [("line",Number 7.0),("character",Number 0.0)])),("end",Object (fromList [("line",Number 7.0),("character",Number 0.0)]))])),("statements",Array [Array [String "unwords aaaa",Number 6.0]])])]), _workDoneToken = Nothing}}
Exception: haskell-language-server-0.2.1-linux-8.8.2: unable to load package `ghc-prim-0.5.3'
[Error - 11:33:30 AM] Request workspace/executeCommand failed.
  Message: haskell-language-server-0.2.1-linux-8.8.2: unable to load package `ghc-prim-0.5.3'
  Code: -32603 

Repository with the simplest project allowing me to reproduce this issue: https://github.com/paweln1986/eval-issue

@lukel97
Copy link
Collaborator

lukel97 commented Jul 23, 2020

Thanks for the test repo, that really helps
I wasn't able to recreate this on Mac unfortunately, but it looks like something weird is going on with
/home/someUser/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.2/lib/ghc-8.8.2/ghc-prim-0.5.3/HSghc-prim-0.5.3.o
I'm not sure why ghc-tinfo is downloaded into the ~/.stack/programs directory, I thought it only contained ghc downloads? But I'm not at a stack expert:

$ ls ~/.stack/programs/x86_64-osx/
ghc-8.10.1           ghc-8.2.2            ghc-8.6.5            ghc-8.8.2            ghc-8.8.3
ghc-8.10.1.installed ghc-8.2.2.installed  ghc-8.6.5.installed  ghc-8.8.2.installed  ghc-8.8.3.installed
ghc-8.10.1.tar.bz2   ghc-8.2.2.tar.bz2    ghc-8.6.5.tar.bz2    ghc-8.8.2.tar.bz2    ghc-8.8.3.tar.bz2

If you don't mind rebuilding/redownloading stuff, could you try deleting ~/.stack and .stack-work and see if it helps?

@paweln1986
Copy link
Author

Unfortunately after removing ~/.stack and .stack-work the problem still persists

@lukel97
Copy link
Collaborator

lukel97 commented Jul 23, 2020

I'm just noticing now that your logs are downloading ghc-8.8.2, but the project's snapshot lts-16.6 should be ghc-8.8.3. Do other features work like error diagnostics and document symbols?

@lukel97
Copy link
Collaborator

lukel97 commented Jul 23, 2020

Also can you post the output of running

/home/someUser/.config/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-wrapper-0.2.1-linux --project-ghc-version

in the project directory, just to make sure the project ghc version detection isn't doing anything weird

@pepeiborra
Copy link
Collaborator

I'm just noticing now that your logs are downloading ghc-8.8.2, but the project's snapshot lts-16.6 should be ghc-8.8.3. Do other features work like error diagnostics and document symbols?

This. The haskell-language-server binary needs to be compiled by the same ghc installation used to build the project.

How did you install Haskell-language-server?

@lukel97
Copy link
Collaborator

lukel97 commented Jul 23, 2020

@pepeiborra looks like through the automatic download given the location of the binaries

@paweln1986
Copy link
Author

paweln1986 commented Jul 23, 2020

The difference of the GHC version in those two logs is because I bumped the version of stack resolver to verify if this issue is related to GHC version.
Output of ~/.config/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-wrapper-0.2.1-linux

Found "/home/someUser/project/haskell/test-issue/hie.yaml" for "/home/someUser/project/haskell/test-issue/a"
Module "/home/someUser/project/haskell/test-issue/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/someUser/project/haskell/test-issue", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper-0.2.1-linux) Version 0.2.1.0, Git revision e8812c18d2be311c6b52545a0dc2b1408f8fa4b2 (dirty) x86_64 ghc-8.10.1
Current directory: /home/someUser/project/haskell/test-issue
Operating system: linux
Arguments: []
Cradle directory: /home/someUser/project/haskell/test-issue
Cradle type: Stack
Consulting the cradle to get project GHC version...
Project GHC version: 8.8.3
haskell-language-server exe candidates: ["haskell-language-server-8.8.3","haskell-language-server-8.8","haskell-language-server"]
Cannot find any haskell-language-server exe, looked for: haskell-language-server-8.8.3, haskell-language-server-8.8, haskell-language-server

Binary of HLS was automatically installed by VSCode plugin.
Also, other feature works without any problems. I can see documentation, VSCode suggests type signature of a function.
I noticed another issue when TemplateHaskell pragma is used:

{-# LANGUAGE TemplateHaskell #-}
module Lib
    ( someFunc
    ) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Base.hs:733:16 in unordered-containers-0.2.11.0-fad0aad3e3deab0594b70513441a5eef969fad7c39bde432b7beca5a0ea273f2:Data.HashMap.Base
  !, called at src/Development/IDE/Import/DependencyInformation.hs:107:40 in ghcide-0.2.0-inplace:Development.IDE.Import.DependencyInformation

@aschmois
Copy link

Commenting here since I think it's specifically the same issue and nothing to do with the vscode extension. From the other issue:

Details

Steps taken

Cleaned out all of ghc and stack and existing haskell binaries and reinstalled everything with the same result.

Error:

After letting the extension load I get "problems" on 11 random files with

{
	"resource": "/home/user/projects/work-project/library/some/foo/Bar.hs",
	"owner": "Haskell (work-project)",
	"severity": 8,
	"message": "Installation error: unable to load package `ghc-prim-0.5.3'",
	"source": "typecheck",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 2,
	"endColumn": 1
}

Extension output:

[client] run command: "/home/user/.vscode-server/data/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.3 --lsp"
[client] debug command: "/home/user/.vscode-server/data/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.3 --lsp"
[client] server cwd: undefined
haskell-language-server version: 0.2.1.0 (GHC: 8.8.3) (PATH: /home/user/.vscode-server/data/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.3) (GIT hash: e8812c18d2be311c6b52545a0dc2b1408f8fa4b2)
Starting (haskell-language-server)LSP server...
  with arguments: Arguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsVersion = False, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "eval",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "stylish-haskell"]
  in directory: /home/user/projects/work-project
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.02s
2020-07-24 17:25:51.690812281 [ThreadId 21] - Opened text document: file:///home/user/projects/work-project/library/Action/Action.hs
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Base.hs:733:16 in unordered-containers-0.2.11.0-fad0aad3e3deab0594b70513441a5eef969fad7c39bde432b7beca5a0ea273f2:Data.HashMap.Base
  !, called at src/Development/IDE/Import/DependencyInformation.hs:107:40 in ghcide-0.2.0-inplace:Development.IDE.Import.DependencyInformation
2020-07-24 17:25:51.692437351 [ThreadId 63] - Consulting the cradle for "/home/user/projects/work-project/library/Action/Action.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/user/projects/work-project", cradleOptsProg = CradleAction: Stack}
[Error - 5:25:51 PM] haskell-lsp:configuration parse error. NotificationMessage {_jsonrpc = "2.0", _method = WorkspaceDidChangeConfiguration, _params = DidChangeConfigurationParams {_settings = Object (fromList [("haskell",Object (fromList [("logFile",String ""),("hlintOn",Bool True),("formatOnImportOn",Bool True),("enable",Bool True),("indentationRules",Object (fromList [("enabled",Bool False)])),("liquidOn",Bool False),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "brittany"),("trace",Object (fromList [("server",String "off")]))]))])}} "key \"languageServerHaskell\" not found"
> Configuring GHCi with the following packages: work-project
> /home/user/projects/work-project/.stack-work/install/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:/home/user/.stack/snapshots/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:/home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
2020-07-24 17:26:09.290541153 [ThreadId 63] - Using interface files cache dir: /home/user/.cache/ghcide/main-1071c4a8018389024d51dabf6a57567030682bc3
2020-07-24 17:26:09.290977919 [ThreadId 63] - Making new HscEnv[main]
2020-07-24 17:26:12.174854595 [ThreadId 144] - finish: CodeAction (took 0.00s)
2020-07-24 17:26:14.017539293 [ThreadId 7831] - finish: CodeAction:PackageExports (took 1.84s)
2020-07-24 17:26:14.017718205 [ThreadId 7834] - Plugin.makeCodeLens (ideLogger)
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
haskell-language-server-0.2.1-linux-8.8.3: /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
2020-07-24 17:26:31.982351492 [ThreadId 25303] - finish: codeLens (took 17.96s)
2020-07-24 17:26:31.982836488 [ThreadId 25306] - GhcIde.hover entered (ideLogger)
2020-07-24 17:26:31.982929292 [ThreadId 25306] - Hover request at position 18:27 in file: /home/user/projects/work-project/library/Action/Action.hs

Manual HLS output:

Running HLS manually I get something similar: (some stuff redacted, removed repetive errors)

> ~/.vscode-server/data/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.3
haskell-language-server version: 0.2.1.0 (GHC: 8.8.3) (PATH: ~/.vscode-server/data/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.3) (GIT hash: e8812c18d2be311c6b52545a0dc2b1408f8fa4b2)
(haskell-language-server)Ghcide setup tester in ~/projects/foo-project.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in ~/projects/foo-project
Found 1222 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "~/projects/foo-project/library/redacted.hs"
Output from setting up the cradle Cradle {cradleRootDir = "~/projects/foo-project", cradleOptsProg = CradleAction: Stack}
> Configuring GHCi with the following packages: foo-project
> ~/projects/foo-project/.stack-work/install/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:~/.stack/snapshots/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: ~/.cache/ghcide/main-1071c4a8018389024d51dabf6a57567030682bc3
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "~/projects/foo-project/test/redacted.hs"
Output from setting up the cradle Cradle {cradleRootDir = "~/projects/foo-project", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foo-project' component foo-project:test:test with main-is file: ~/projects/foo-project/test/redacted.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: foo-project
> ~/projects/foo-project/.stack-work/install/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:~/.stack/snapshots/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: ~/.cache/ghcide/main-000d2ed3b3c7c55de3530c0d2fa463028e71420f
[INFO] Using interface files cache dir: ~/.cache/ghcide/main-000d2ed3b3c7c55de3530c0d2fa463028e71420f
[INFO] Making new HscEnv[main,main]
[INFO] Consulting the cradle for "~/projects/foo-project/executable/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "~/projects/foo-project", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foo-project' component foo-project:exe:foo-project with main-is file: ~/projects/foo-project/executable/Main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: foo-project
> ~/projects/foo-project/.stack-work/install/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:~/.stack/snapshots/x86_64-linux-tinfo6/3ea20d7672e8fbf87f04e1a3aaf2eadc7ca2fa7f104aac50f76a9bb8664b27ff/8.8.3/pkgdb:~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: ~/.cache/ghcide/main-2d85e50b6f3e807fffe1f3b49a55125f752fe07e
[INFO] Using interface files cache dir: ~/.cache/ghcide/main-2d85e50b6f3e807fffe1f3b49a55125f752fe07e
[INFO] Using interface files cache dir: ~/.cache/ghcide/main-2d85e50b6f3e807fffe1f3b49a55125f752fe07e
[INFO] Making new HscEnv[main,main,main]
[INFO] Consulting the cradle for "~/projects/foo-project/tools/docker/hasktags-daemon.hs"
Output from setting up the cradle Cradle {cradleRootDir = "~/projects/foo-project", cradleOptsProg = CradleAction: Stack}
File:     ~/projects/foo-project/tools/docker/hasktags-daemon.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: ~/projects/foo-project
  filepath: ~/projects/foo-project/tools/docker/hasktags-daemon.hs
  prefixes:
  ("./library",Stack {component = Just "foo-project:lib"})
  ("./executable/Main.hs",Stack {component = Just "foo-project:exe:foo-project"})
  ("./test",Stack {component = Just "foo-project:test:test"})
File:     ~/projects/foo-project/test/redacted.hs
Hidden:   no
Range:    1:0-2:0
Source:   compiler
Severity: DsError
Message:  haskell-language-server-0.2.1-linux-8.8.3: could not execute: hspec-discover
[INFO] Consulting the cradle for "~/projects/foo-project/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/autogen/Paths_foo-project.hs"
Output from setting up the cradle Cradle {cradleRootDir = "~/projects/foo-project", cradleOptsProg = CradleAction: Stack}
File:    
  ~/projects/foo-project/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/autogen/Paths_foo-project.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: ~/projects/foo-project
  filepath:
  ~/projects/foo-project/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/autogen/Paths_foo-project.hs
  prefixes:
  ("./library",Stack {component = Just "foo-project:lib"})
  ("./executable/Main.hs",Stack {component = Just "foo-project:exe:foo-project"})
  ("./test",Stack {component = Just "foo-project:test:test"})
haskell-language-server-0.2.1-linux-8.8.3: ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
File:    
  ~/projects/foo-project/library/redacted.hs
Hidden:   no
Range:    1:0-2:0
Source:   typecheck
Severity: DsError
Message:  Installation error: unable to load package `ghc-prim-0.5.3'
...
[INFO] finish: User TypeCheck (took 54.21s)
Files that failed:
 * ~/projects/foo-project/library/redacted.hs
...
Completed (701 files worked, 521 files failed)

@kafji
Copy link

kafji commented Jul 26, 2020

I can reproduce similar result using Yesod project template.

Ubuntu 20.04
GHC 8.8.3
Stack 2.3.1

> stack new foobar yesodweb/sqlite --bare
> ~/.config/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-linux-8.8.3
...
haskell-language-server-0.2.1-linux-8.8.3: ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
File:     ~/foobar/src/Model.hs
Hidden:   no
Range:    1:0-2:0
Source:   typecheck
Severity: DsError
Message:  Installation error: unable to load package `ghc-prim-0.5.3'
haskell-language-server-0.2.1-linux-8.8.3: ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
File:     ~/foobar/src/Settings.hs
Hidden:   no
Range:    1:0-2:0
Source:   typecheck
Severity: DsError
Message:  Installation error: unable to load package `ghc-prim-0.5.3'
...

@sluukkonen
Copy link

Noticed the same thing with hlint.

(Ubuntu 20.04, GHC 8.10.1, Cabal 3.2.0.0)

> Build profile: -w ghc-8.10.1 -O1
> In order, the following will be built (use -v for more details):
>  - hlint-3.1.6 (lib) (configuration changed)
> Configuring library for hlint-3.1.6..
> Preprocessing library for hlint-3.1.6..
2020-07-26 11:32:41.4774337 [ThreadId 74] - Using interface files cache dir: /home/sluukkonen/.cache/ghcide/hlint-3.1.6-inplace-74dbd16626a09866d31267df3d7d604904dd8f61
2020-07-26 11:32:41.4777295 [ThreadId 74] - Making new HscEnv[hlint-3.1.6-inplace]
2020-07-26 11:32:41.5809824 [ThreadId 251] - finish: CodeAction (took 0.00s)
haskell-language-server-0.2.1-linux-8.10.1: /home/sluukkonen/.ghcup/ghc/8.10.1/lib/ghc-8.10.1/ghc-prim-0.6.1/HSghc-prim-0.6.1.o: unknown symbol `exp'```

@lukel97
Copy link
Collaborator

lukel97 commented Jul 26, 2020

On macOS with the 0.2.1 binary the yesod project template segfaults, with a separate issue not-related to ghc-prim:

$ ~/Library/Application\ Support/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-darwin-8.8.3 
haskell-language-server version: 0.2.1.0 (GHC: 8.8.3) (PATH: /Users/luke/Library/Application Support/Code/User/globalStorage/alanz.vscode-hie-server/haskell-language-server-0.2.1-darwin-8.8.3) (GIT hash: e8812c18d2be311c6b52545a0dc2b1408f8fa4b2)
(haskell-language-server)Ghcide setup tester in /Users/luke/Downloads/ghc-prim-hls-bug.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/luke/Downloads/ghc-prim-hls-bug
Found 20 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/test/TestImport.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: foobar
> /Users/luke/Downloads/ghc-prim-hls-bug/.stack-work/install/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/snapshots/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/test/Handler/CommonSpec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: foobar
> /Users/luke/Downloads/ghc-prim-hls-bug/.stack-work/install/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/snapshots/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Making new HscEnv[main,main]
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/test/Handler/HomeSpec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: foobar
> /Users/luke/Downloads/ghc-prim-hls-bug/.stack-work/install/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/snapshots/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Making new HscEnv[main,main,main]
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/test/Handler/CommentSpec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: foobar
> /Users/luke/Downloads/ghc-prim-hls-bug/.stack-work/install/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/snapshots/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Making new HscEnv[main,main,main,main]
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/test/Handler/ProfileSpec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: foobar
> /Users/luke/Downloads/ghc-prim-hls-bug/.stack-work/install/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/snapshots/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Making new HscEnv[main,main,main,main,main]
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/test/Spec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: foobar
> /Users/luke/Downloads/ghc-prim-hls-bug/.stack-work/install/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/snapshots/x86_64-osx/cb58d8e1ef42856f0c48ee734a2170c6690f7e642c1d792384de9b418d6b6337/8.8.3/pkgdb:/Users/luke/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Using interface files cache dir: /Users/luke/.cache/ghcide/main-538dec54e43cb8db3f3cf725a38ca1a92121d082
[INFO] Making new HscEnv[main,main,main,main,main,main]
File:     /Users/luke/Downloads/ghc-prim-hls-bug/test/Spec.hs
Hidden:   no
Range:    1:0-2:0
Source:   compiler
Severity: DsError
Message:  haskell-language-server-0.2.1-darwin-8.8.3: could not execute: hspec-discover
[INFO] Consulting the cradle for "/Users/luke/Downloads/ghc-prim-hls-bug/app/devel.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/luke/Downloads/ghc-prim-hls-bug", cradleOptsProg = CradleAction: Stack}
File:     /Users/luke/Downloads/ghc-prim-hls-bug/test/TestImport.hs
Hidden:   no
Range:    15:7-15:17
Source:   not found
Severity: DsError
Message: 
  Could not find module ‘Test.Hspec’
  It is not a module in the current program, or in any known package.
File:     /Users/luke/Downloads/ghc-prim-hls-bug/test/TestImport.hs
Hidden:   no
Range:    18:7-18:17
Source:   not found
Severity: DsError
Message: 
  Could not find module ‘Yesod.Test’
  Perhaps you meant
  Yesod.Feed (needs flag -package-key yesod-newsfeed-1.7.0.0)
File:     /Users/luke/Downloads/ghc-prim-hls-bug/test/TestImport.hs
Hidden:   no
Range:    24:7-24:17
Source:   not found
Severity: DsError
Message: 
  Could not load module ‘Lens.Micro’
  It is a member of the hidden package ‘microlens-0.4.11.2’.
  You can run ‘:set -package microlens’ to expose it.
  (Note: this unloads all the modules in the current scope.)
> Using main module: 1. Package `foobar' component foobar:exe:foobar with main-is file: /Users/luke/Downloads/ghc-prim-hls-bug/app/main.hs
Segmentation fault: 11

@georgefst
Copy link
Collaborator

I'm hitting this on a fresh install via the VScode extension when opening a file containing Template Haskell. GHC 8.10.1. Ubuntu 16.

Everything was working fine with my previous locally-built version (from the HEAD of the Fourmolu branch), but I had to upgrade due to the settings name mismatch issue.

@paweln1986
Copy link
Author

I can confirm this issue persist only with binary downloaded by VSCode extension. If I build HLS from source, eval plugin works as expected.

@lukel97
Copy link
Collaborator

lukel97 commented Jul 29, 2020

I can only imagine --enable-executable-static is doing something that's causing libm not to be linked in. That unknown symbol exp is coming from the GHC RTS linker. Just to summarise where this happens:

  • Linux static binaries
  • On ghc-8.8.3 and ghc-8.10.1 so far
  • Disabling split-sections doesn't fix it
  • Happens on cabal + stack projects
  • Happens on plain files actually

@amesgen
Copy link
Contributor

amesgen commented Jul 29, 2020

Maybe statically linking to glibc (which libm is part of) is the culprit? Also see this comment on /r/haskell.

@lukel97
Copy link
Collaborator

lukel97 commented Jul 29, 2020

@amesgen I'm going to try building hls inside ghc-musl and see what happens

@lukel97
Copy link
Collaborator

lukel97 commented Jul 29, 2020

I have a binary built with ghc-musl now, but unfortunately the ghc-prim issue still persists with it

@lukel97 lukel97 changed the title unable to load package `ghc-prim-0.5.3' using evaluate comment feature Eval feature gives linker error on statically linked binaries on Linux Jul 31, 2020
@lukel97 lukel97 changed the title Eval feature gives linker error on statically linked binaries on Linux Statically linked Linux binaries cannot run interactive session Aug 6, 2020
@lukel97 lukel97 pinned this issue Aug 6, 2020
@lukel97 lukel97 self-assigned this Aug 6, 2020
@lukel97
Copy link
Collaborator

lukel97 commented Aug 6, 2020

The current fix it looks like is to dynamically load libm.so when the GHC session is created with https://hackage.haskell.org/package/ghc-8.10.1/docs/GHCi.html#v:loadDLL

@lukel97
Copy link
Collaborator

lukel97 commented Aug 6, 2020

It is worth noting that this trick does not work when statically linked with musl, since musl doesn't support dynamic loading (dlopen) from static binaries https://github.com/bminor/musl/blob/73cc775bee53300c7cf759f37580220b18ac13d3/WHATSNEW#L254
https://github.com/bminor/musl/blob/da55d4884bf26ce31cd6a64ed176019c2ba9839a/src/ldso/dlopen.c#L10

@lukel97
Copy link
Collaborator

lukel97 commented Aug 6, 2020

Building binaries with the a fix now. If anyone has some spare time and wants to check that this does indeed fix it, your testing would be much appreciated! https://github.com/bubba/haskell-language-server/releases/tag/libmfix0

@k-bx
Copy link

k-bx commented Aug 6, 2020

@bubba happy to test (had this error). How exactly should that be done? Previously I had an error when just trying to make VSCode do all the job (setup etc.), I assume something extra needs to be done for it to use the tag.

@sluukkonen
Copy link

Building binaries with the a fix now. If anyone has some spare time and wants to check that this does indeed fix it, your testing would be much appreciated! https://github.com/bubba/haskell-language-server/releases/tag/libmfix0

It fixed the issue on my machine. 🎉

@aschmois
Copy link

aschmois commented Aug 6, 2020

I tried the new binary and it looks like hls gets stuck at 100% cpu while loading some files. Not sure if it's related to my project though, when I have some time I'll attempt to run it on a simpler project.

@lukel97
Copy link
Collaborator

lukel97 commented Aug 6, 2020

@k-bx if you head to the release page and download the corresponding haskell-language-server-Linux for whatever GHC version your project was using, decompress that and then go into the VSCode settings. Search for Haskell server path and set that path to the decompressed binary, then reload VS Code. Try opening up a file with template Haskell or using the eval plugin. If anything goes wrong can you upload the contents from the output window > Haskell tab?

@k-bx
Copy link

k-bx commented Aug 6, 2020

@bubba thank you for the instructions! It now launched indeed but seems to be hanging in this "Processing: 45/68" state eating 100% of one CPU, similar to an aforementioned problem.

UPDATE: found it (needed to choose the dropdown on the right): https://gist.github.com/k-bx/b92edee5542f05f35b7652e626c0d34c

@codygman
Copy link

codygman commented Aug 6, 2020

So @aschmois and I are working with the same codebase. I thought the problem is that we have a 13GB .docker folder that's being slurped up in the expandFiles function in the initialization at the beginning here.

But I see it's ignoring hidden directories in it's definition:

expandFiles :: [FilePath] -> IO [FilePath]
expandFiles = concatMapM $ \x -> do
    b <- IO.doesFileExist x
    if b then return [x] else do
        let recurse "." = True
            recurse x | "." `isPrefixOf` takeFileName x = False -- skip .git etc
            recurse x = takeFileName x `notElem` ["dist","dist-newstyle"] -- cabal directories
        files <- filter (\x -> takeExtension x `elem` [".hs",".lhs"]) <$> IO.listFilesInside (return . recurse) x
        when (null files) $
            fail $ "Couldn't find any .hs/.lhs files inside directory: " ++ x
        return files

Edit: I tried looking into this further, but got hung up by #294

@balajirrao
Copy link

balajirrao commented Aug 6, 2020

Adding -fexternal-interpreter to ghc-options is a workaround that works for me.

-fexternal-interpreter results in this path to be taken, which leads to libHSghc-prim-0.5.3-ghc8.6.5.so being loaded instead of HSghc-prim-0.5.3.o. Loading the shared library instead of the object file then seems to take care of loading libm.

~> ldd libHSghc-prim-0.5.3-ghc8.6.5.so 
	linux-vdso.so.1 (0x00007fffafdf4000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f56615c0000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f56613ce000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5661bb4000)

Testing this workaround is much appreciated!

(btw, -fexternal-interpreter doesn't work when using ghc plugins)

@lukel97
Copy link
Collaborator

lukel97 commented Aug 6, 2020

@k-bx well I can't see the ghc-prim error in the log so looks like that's one problem solved! If you haven't built the project before with cabal/stack it may take some time depending on the size as it builds dependencies etc. It might be a good idea to call cabal build/stack build on the project before launching the editor just to make sure things are working

@berberman
Copy link
Collaborator

berberman commented Aug 7, 2020

I can reproduce it when the language extension TemplateHaskell is enabled.
This #221 (comment) works for me, thanks!

Environment

System: Archlinux
Stack version: 2.3.1
Sandbox GHC version: 8.8.3
HLS version: 0.2.2.0 (installed from source instead of the pre-built downloaded by the vscode plugin)

Screenshot

The error message will hover above the first extension, and functionalities provided by hls are no longer avaliable.

pic

Vscode output

haskell-language-server version: 0.2.2.0 (GHC: 8.8.3) (PATH: /home/berberman/.config/Code - OSS/User/globalStorage/haskell.haskell/haskell-language-server-0.2.2-linux-8.8.3) (GIT hash: e44f618c11b7978264a94beeee00d1f014867f6d)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "eval",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "stylish-haskell"]
  in directory: /home/berberman/Desktop/tg-echobot
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.00s
2020-08-07 10:00:17.206768547 [ThreadId 21] - Opened text document: file:///home/berberman/Desktop/tg-echobot/Setup.hs
2020-08-07 10:00:17.207139324 [ThreadId 21] - Opened text document: file:///home/berberman/Desktop/tg-echobot/src/API.hs
2020-08-07 10:00:17.207473609 [ThreadId 21] - Opened text document: file:///home/berberman/Desktop/tg-echobot/src/Lib.hs
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Base.hs:733:16 in unordered-containers-0.2.11.0-fad0aad3e3deab0594b70513441a5eef969fad7c39bde432b7beca5a0ea273f2:Data.HashMap.Base
  !, called at src/Development/IDE/Import/DependencyInformation.hs:107:40 in ghcide-0.2.0-inplace:Development.IDE.Import.DependencyInformation
2020-08-07 10:00:17.208082393 [ThreadId 99] - Consulting the cradle for "/home/berberman/Desktop/tg-echobot/src/Lib.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/berberman/Desktop/tg-echobot", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `tg-echobot' component tg-echobot:exe:tg-echobot-exe with main-is file: /home/berberman/Desktop/tg-echobot/app/Main.hs
> tg-echobot> configure (lib + exe)
> Configuring tg-echobot-0.1.0.0...
> tg-echobot> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: tg-echobot
> /home/berberman/Desktop/tg-echobot/.stack-work/install/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/snapshots/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
2020-08-07 10:00:19.737996963 [ThreadId 99] - Using interface files cache dir: /home/berberman/.cache/ghcide/main-43cd83fa8f34522d29a85008319044e21ffb7337
2020-08-07 10:00:19.738172583 [ThreadId 99] - Making new HscEnv[main]
2020-08-07 10:00:19.756607828 [ThreadId 151] - Consulting the cradle for "/home/berberman/Desktop/tg-echobot/Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/berberman/Desktop/tg-echobot", cradleOptsProg = CradleAction: Stack}
2020-08-07 10:00:19.765391886 [ThreadId 194] - Plugin.makeCodeLens (ideLogger)
> Using main module: 1. Package `tg-echobot' component tg-echobot:exe:tg-echobot-exe with main-is file: /home/berberman/Desktop/tg-echobot/app/Main.hs
> tg-echobot> configure (lib + exe)
> Configuring tg-echobot-0.1.0.0...
> tg-echobot> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: tg-echobot
> /home/berberman/Desktop/tg-echobot/.stack-work/install/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/snapshots/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
2020-08-07 10:00:22.265124867 [ThreadId 151] - Using interface files cache dir: /home/berberman/.cache/ghcide/main-43cd83fa8f34522d29a85008319044e21ffb7337
2020-08-07 10:00:22.265308738 [ThreadId 151] - Using interface files cache dir: /home/berberman/.cache/ghcide/main-43cd83fa8f34522d29a85008319044e21ffb7337
2020-08-07 10:00:22.265370274 [ThreadId 151] - Making new HscEnv[main,main]
haskell-language-server-0.2.2-linux-8.8.3: /home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `exp'
2020-08-07 10:00:22.711023315 [ThreadId 2145] - finish: codeLens (took 0.43s)

Directly run haskell-language-server in terminal

❯ haskell-language-server
haskell-language-server version: 0.2.2.0 (GHC: 8.8.3) (PATH: /home/berberman/.local/bin/haskell-language-server) (GIT hash: 4fe0f7dfc1cac850a1a1a201fff41cdecc0fb7cf)
(haskell-language-server)Ghcide setup tester in /home/berberman/Desktop/tg-echobot.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /home/berberman/Desktop/tg-echobot
Found 6 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "/home/berberman/Desktop/tg-echobot/src/Eval.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/berberman/Desktop/tg-echobot", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `tg-echobot' component tg-echobot:exe:tg-echobot-exe with main-is file: /home/berberman/Desktop/tg-echobot/app/Main.hs
> tg-echobot> configure (lib + exe)
> Configuring tg-echobot-0.1.0.0...
> tg-echobot> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: tg-echobot
> /home/berberman/Desktop/tg-echobot/.stack-work/install/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/snapshots/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-43cd83fa8f34522d29a85008319044e21ffb7337
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "/home/berberman/Desktop/tg-echobot/Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/berberman/Desktop/tg-echobot", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `tg-echobot' component tg-echobot:exe:tg-echobot-exe with main-is file: /home/berberman/Desktop/tg-echobot/app/Main.hs
> tg-echobot> configure (lib + exe)
> Configuring tg-echobot-0.1.0.0...
> tg-echobot> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2 -threaded
> Configuring GHCi with the following packages: tg-echobot
> /home/berberman/Desktop/tg-echobot/.stack-work/install/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/snapshots/x86_64-linux-tinfo6/7bbede4b33f794c8e999f1858f1f1b63f1e9f79200f9333355994f9b740032e1/8.8.3/pkgdb:/home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-43cd83fa8f34522d29a85008319044e21ffb7337
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-43cd83fa8f34522d29a85008319044e21ffb7337
[INFO] Making new HscEnv[main,main]
[INFO] finish: User TypeCheck (took 0.56s)

Completed (6 files worked, 0 files failed)

GHC Info

❯ stack exec ghc -- --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv -fno-builtin")
 ,("C compiler command","gcc")
 ,("C compiler flags","")
 ,("C compiler link flags"," -fuse-ld=gold")
 ,("C compiler supports -no-pie","YES")
 ,("Haskell CPP command","gcc")
 ,("Haskell CPP flags","-E -undef -traditional")
 ,("ld command","ld.gold")
 ,("ld flags","")
 ,("ld supports compact unwind","YES")
 ,("ld supports build-id","YES")
 ,("ld supports filelist","NO")
 ,("ld is GNU ld","YES")
 ,("ar command","ar")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("ranlib command","ranlib")
 ,("touch command","touch")
 ,("dllwrap command","/bin/false")
 ,("windres command","/bin/false")
 ,("libtool command","libtool")
 ,("perl command","/usr/bin/perl")
 ,("cross compiling","NO")
 ,("target os","OSLinux")
 ,("target arch","ArchX86_64")
 ,("target word size","8")
 ,("target has GNU nonexec stack","True")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("target has RTS linker","YES")
 ,("Unregisterised","NO")
 ,("LLVM llc command","llc")
 ,("LLVM opt command","opt")
 ,("LLVM clang command","clang")
 ,("Project version","8.8.3")
 ,("Project Git commit id","d0bab2e3419e49cdbb1201d4650572b57f33420c")
 ,("Booter version","8.4.4")
 ,("Stage","2")
 ,("Build platform","x86_64-unknown-linux")
 ,("Host platform","x86_64-unknown-linux")
 ,("Target platform","x86_64-unknown-linux")
 ,("Have interpreter","YES")
 ,("Object splitting supported","YES")
 ,("Have native code generator","YES")
 ,("Support SMP","YES")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn thr_debug_p debug_p")
 ,("RTS expects libdw","NO")
 ,("Support dynamic-too","YES")
 ,("Support parallel --make","YES")
 ,("Support reexported-modules","YES")
 ,("Support thinning and renaming package flags","YES")
 ,("Support Backpack","YES")
 ,("Requires unified installed package IDs","YES")
 ,("Uses package keys","YES")
 ,("Uses unit IDs","YES")
 ,("Dynamic by default","NO")
 ,("GHC Dynamic","YES")
 ,("GHC Profiled","NO")
 ,("Leading underscore","NO")
 ,("Debug on","False")
 ,("LibDir","/home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3")
 ,("Global Package DB","/home/berberman/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d")
 ]

@balajirrao
Copy link

Building binaries with the a fix now. If anyone has some spare time and wants to check that this does indeed fix it, your testing would be much appreciated! https://github.com/bubba/haskell-language-server/releases/tag/libmfix0

Fixes the issue for me as well, thanks!

@k-bx
Copy link

k-bx commented Aug 7, 2020

@k-bx well I can't see the ghc-prim error in the log so looks like that's one problem solved! If you haven't built the project before with cabal/stack it may take some time depending on the size as it builds dependencies etc. It might be a good idea to call cabal build/stack build on the project before launching the editor just to make sure things are working

Yes indeed, seems like it's a different problem now. Re building project – no, it builds fine with stack build, so not really sure what the problem is.

@lukel97
Copy link
Collaborator

lukel97 commented Aug 7, 2020

@k-bx can you open a new issue for your case? Also are you able to share the project that this is happening on?

@k-bx
Copy link

k-bx commented Aug 7, 2020

@bubba the project happens to be open-source already https://github.com/k-bx/emotive_conjugations

I'll try to find some time to make a proper issue, thanks!

@lukel97 lukel97 unpinned this issue Aug 7, 2020
fendor pushed a commit to fendor/haskell-language-server that referenced this issue Aug 10, 2020
@polux
Copy link

polux commented Sep 9, 2020

I'm still getting a similar error in files using template haskell. This is using vscode inside a nix shell and version 0.4.0 of HLS downloaded by the vscode plugin:

Unexpected usage error
can't load .so/.DLL for: /nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/librt.so (/nix/store/c745s6cnnxy6c98bvhi0qsijrh3ikag1-glibc-2.27/lib/librt.so: symbol __clock_nanosleep version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference)

@puffnfresh
Copy link

@polux I had the same problem. I got HLS to find libm by putting glibc on my LD_LIBRARY_PATH using a shellHook:

let
  pkgs =
    import <nixpkgs> { };
in
(import ./.).shellFor {
  packages = ps: [ ps.cubix ];
  exactDeps = true;
  tools.cabal = "3.2.0.0";
  shellHook = ''
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${pkgs.glibc}/lib
  '';
}

@polux
Copy link

polux commented Oct 5, 2020

@puffnfresh thanks! Unfortunately in my case this leads to a segfault when I launch vscode downloaded from https://code.visualstudio.com/. If I try to install my nixpkg's vscode then I get an old version which is not compatible with the haskell extension. If I install (import <nixpkgs> {}).pkgs.vscode then I get a segfault again. The problem is probably that my libc is too old because I'm working on a ghcjs project which uses the nix setup of the miso project, which must be an old snapshot of nixpkgs. What I'd need to do is to somehow force vscode to launch hls with the right LD_LIBRARY_PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests