Skip to content

Prelude.head: empty list makes hls unusable until restart #1618

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

Closed
codygman opened this issue Mar 24, 2021 · 5 comments
Closed

Prelude.head: empty list makes hls unusable until restart #1618

codygman opened this issue Mar 24, 2021 · 5 comments
Labels
component: hie-bios status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@codygman
Copy link

codygman commented Mar 24, 2021

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

~/work-repo $ haskell-language-server --probe-tools
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /nix/store/1ngys7bwknlk8mixh5x3cxzxpnzn83ya-haskell-language-server-1.0.0.0/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:		3.0.0.0
stack:		2.5.1.1
ghc:		8.10.4

Which lsp-client do you use:
lsp-mode in emacs

Describe your project (alternative: link to the project):
n/a

Steps to reproduce

I'm not quite sure.

Expected behaviour

HLS should not die with a Prelude.head empty list error or at least report an error with call stack information

Actual behaviour

HLS seems "stuck" until restart

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

I don't have time to take out information that I might be unable to share right now.

Debug output:
<paste your logs here>

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
Found "/home/cody/work-proj/hie.yaml" for "/home/cody/work-proj/a"
Module "/home/cody/work-proj/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/cody/work-proj", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.0.0.0 x86_64 ghc-8.10.4
Current directory: /home/cody/work-proj
Operating system: linux
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /home/cody/work-proj
Cradle type: Stack

Tool versions found on the $PATH
cabal:		3.0.0.0
stack:		2.5.1.1
ghc:		8.10.4


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.4
haskell-language-server exe candidates: ["haskell-language-server-8.10.4","haskell-language-server-8.10","haskell-language-server"]
Launching haskell-language-server exe at:/run/current-system/sw/bin/haskell-language-server-8.10.4
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /nix/store/1ngys7bwknlk8mixh5x3cxzxpnzn83ya-haskell-language-server-1.0.0.0/bin/haskell-language-server)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "class",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide-code-actions",PluginId "ghcide-completions",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-type-lenses",PluginId "haddockComments",PluginId "hlint",PluginId "importLens",PluginId "moduleName",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "splice",PluginId "stylish-haskell",PluginId "tactic"]
  in directory: /home/cody/work-proj
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
Starting LSP server...
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.00s
setInitialDynFlags cradle: Cradle {cradleRootDir = "/home/cody/work-proj", cradleOptsProg = CradleAction: Stack}
Output from setting up the cradle Cradle {cradleRootDir = "/home/cody/work-proj", cradleOptsProg = CradleAction: Stack}
> work-proj> configure (lib)
> Configuring work-proj-9003...
> work-proj> initial-build-steps (lib)
> Configuring GHCi with the following packages: work-proj
> /home/cody/work-proj/.stack-work/install/x86_64-linux-nix/bf73507d5ab7d23ffbc635ca9a779c93abe2b07d289a0605721872c193f83a77/8.10.4/pkgdb:/home/cody/.stack/snapshots/x86_64-linux-nix/bf73507d5ab7d23ffbc635ca9a779c93abe2b07d289a0605721872c193f83a77/8.10.4/pkgdb:/nix/store/26zbw2cg6w0ih8gr5ab8vh670mccrd3v-ghc-8.10.4/lib/ghc-8.10.4/package.conf.d
haskell-language-server-8.10.4: Prelude.head: empty list

What is /home/cody/work-proj/a? ls shows me file not found. Is that something synthetic hls adds?

@codygman codygman changed the title haskell-language-server-8.10.4: Prelude.head: empty list makes hls unusable until restart Prelude.head: empty list makes hls unusable until restart Mar 24, 2021
@jneira
Copy link
Member

jneira commented Mar 24, 2021

Thanks for the bug report. Is it reproduced after building the project with stack build and restarting hls?

What is /home/cody/work-proj/a? ls shows me file not found. Is that something synthetic hls adds?

It is a fake path hls is using to load the cradle iirc

//cc @fendor

@jneira jneira added build tool: stack component: hie-bios type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: setup labels Mar 24, 2021
@fendor
Copy link
Collaborator

fendor commented Mar 24, 2021

@jneira, yep, that path should be fine.

@pepeiborra
Copy link
Collaborator

is this still a problem?

@jneira jneira added the status: needs info Not actionable, because there's missing information label Jun 8, 2021
@lehins
Copy link

lehins commented Aug 4, 2021

I just ran into the exact same issue:

haskell-language-server-8.10.4: Prelude.head: empty list

Relevant version info:

Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.3.0.0, Git revision e7c5e90b6df5dff2760d76169eddaea3bdd6a831 (dirty) x86_64 ghc-8.10.4
Cradle type: Cabal

Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.7.3
ghc:		8.10.4

Why would anyone use head??? It should really be removed from base or even better switched to head :: [a] -> Maybe a

@fendor
Copy link
Collaborator

fendor commented Mar 13, 2024

I think this should be fixed by now, reopen if still an issue!

@fendor fendor closed this as completed Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hie-bios status: needs info Not actionable, because there's missing information 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

7 participants