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

HLS 1.5 requires hie.yaml else it would fail to run, but works in HLS 1.2 #2398

Closed
sekunho opened this issue Nov 25, 2021 · 20 comments
Closed
Labels
component: implicit-hie os: nixos type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@sekunho
Copy link

sekunho commented Nov 25, 2021

Hello, thanks again for all the work put into HLS!

Your environment

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

haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /nix/store/ngi32ilj18ppcc78g0kc3z3zq4r3s049-haskell-language-server-1.5.0.0/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:		3.6.2.0
stack:		Not found
ghc:		8.10.7

Which OS do you use:
NixOS 21.05

Which lsp-client do you use:
doom emacs v21.12.0-alpha with haskell mode

Describe your project (alternative: link to the project):
It's a newly generated project with cabal init --interactive with nix flakes to provide the HLS, cabal, and GHC. https://gist.github.com/sekunho/72747c20a192e62a6fc9dc9e9660aa0a

Contents of hie.yaml:
N/A

Steps to reproduce

  1. nix develop (or direnv)
  2. haskell-language-server --debug
  3. Fails to start cause of error

However, it works if I do:

  1. gen-hie > hie.yaml
  2. haskell-language-server

It's strange because when I pin a commit of nixpkgs to one that contains HLS 1.2.0.0 and ghc 8.10.6, it works. It doesn't work with HLS 1.5.0.0 and GHC 8.10.7. How come 1.5 requires hie.yaml while 1.2 doesn't?

Expected behaviour

Shouldn't complain about a bad file descriptor without hie.yaml since it works for 1.2.

Actual behaviour

Complains about a bad file descriptor without it.

Include debug information

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

Debug output:
# haskell-language-server --debug

[sekun@nixos:~/Projects/foo]$ haskell-language-server --debug
haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /nix/store/ngi32ilj18ppcc78g0kc3z3zq4r3s049-haskell-language-server-1.5.0.0/bin/haskell-language-server)
 ghcide setup tester in /home/sekun/Projects/foo.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /home/sekun/Projects/foo
Found 2 files

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

Step 3/4: Initializing the IDE
2021-11-25 14:39:32.955603396 [ThreadId 7] DEBUG hls:	Initializing exports map from hiedb

Step 4/4: Type checking 2021-11-25 14:39:32.956138658 [ThreadId 7] DEBUG hls:	Done initializing exports map from hiedb (0)
the files
2021-11-25 14:39:32.956815549 [ThreadId 31] INFO hls:	Consulting the cradle for "src/Foo.hs"
2021-11-25 14:39:32.956900639 [ThreadId 31] WARNING hls:	No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src/Foo.hs.
 Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2021-11-25 14:39:32.970625984 [ThreadId 31] DEBUG hls:	Output from setting up the cradle Cradle {cradleRootDir = "", cradleOptsProg = CradleAction: Cabal}
2021-11-25 14:39:32.972146247 [ThreadId 27] INFO hls:	File:     /home/sekun/Projects/foo/src/Foo.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message:  cabal: streamingProcess: chdir: invalid argument (Bad file descriptor)
2021-11-25 14:39:32.972431128 [ThreadId 30] INFO hls:	File:     /home/sekun/Projects/foo/test/MyLibTest.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message:  cabal: streamingProcess: chdir: invalid argument (Bad file descriptor)
2021-11-25 14:39:32.972707809 [ThreadId 19] INFO hls:	finish: User TypeCheck (took 0.02s)
2021-11-25 14:39:32.972927379 [ThreadId 42] INFO hls:	finish: GetHie (took 0.00s)
F2021-11-25 14:39:32.97316226 [ThreadId 49] INFO hls:	finish: GenerateCore (took 0.00s)
iles that failed:
 * /home/sekun/Projects/foo/src/Foo.hs
 * /home/sekun/Projects/foo/test/MyLibTest.hs

Completed (0 files worked, 2 files failed)

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

LSP logs:
# lsp-log buffer
Command "haskell-language-server --lsp -d -l /tmp/hls.log" is present on the path.
Command "haskell-language-server --lsp -d -l /tmp/hls.log" is present on the path.
Command "haskell-language-server --lsp -d -l /tmp/hls.log" is present on the path.
Found the following clients for /home/sekun/Projects/foo/src/Foo.hs: (server-id lsp-haskell, priority 0)
The following clients were selected based on priority: (server-id lsp-haskell, priority 0)
Creating watchers for following 3 folders:
  /home/sekun/Projects/foo
  /home/sekun/Projects/foo/src
  /home/sekun/Projects/foo/test

# lsp-haskell::stderr
haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /nix/store/ngi32ilj18ppcc78g0kc3z3zq4r3s049-haskell-language-server-1.5.0.0/bin/haskell-language-server)
Starting (haskell-language-server)LSP server...
  with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"]
  in directory: /home/sekun/Projects/foo
 Couldn't load cradle for libdir: (CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Couldn't execute cabal --builddir=/home/sekun/.cache/hie-bios/dist-foo-7de3951b2299bde2ff8672638cbcd53f v2-exec --with-compiler /home/sekun/.cache/hie-bios/wrapper-13a09b18ea883dd377d59db5e821a86b ghc -v0 -- --print-libdir"]},"/home/sekun/Projects/foo",Nothing,Cradle {cradleRootDir = "", cradleOptsProg = CradleAction: Cabal})
@jneira jneira added component: hie-bios type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: setup labels Nov 25, 2021
@jneira
Copy link
Member

jneira commented Nov 25, 2021

thanks for reporting the issue
have those directories something special: filesystem, perms, hard links?

How come 1.5 requires hie.yaml while 1.2 doesn't?

hie.yaml should not be necessary so it is a bug probably related with the hie-bios library

//cc @fendor

@sekunho
Copy link
Author

sekunho commented Nov 25, 2021

have those directories something special: filesystem, perms, hard links?

How do I check for this?

@jneira
Copy link
Member

jneira commented Nov 25, 2021

hmm ls -la and df . in ~/Projects/foo? i am not a linux expert though

@sekunho
Copy link
Author

sekunho commented Nov 25, 2021

Ah got it.

[sekun@nixos:~/Projects/foo]$ ls -la
total 76
drwxr-xr-x 7 sekun users  4096 Nov 25 15:12 .
drwxr-xr-x 7 sekun users  4096 Nov 25 11:39 ..
-rw-r--r-- 1 sekun users   115 Nov 25 11:58 CHANGELOG.md
drwxr-xr-x 3 sekun users  4096 Nov 25 15:12 .direnv
drwxr-xr-x 6 sekun users  4096 Nov 25 12:01 dist-newstyle
-rw-r--r-- 1 sekun users    10 Nov 25 15:12 .envrc
-rw-r--r-- 1 sekun users   992 Nov 25 15:01 flake.lock
-rw-r--r-- 1 sekun users   696 Nov 25 15:11 flake.nix
drwxr-xr-x 8 sekun users  4096 Nov 25 15:11 .git
-rw-r--r-- 1 sekun users   293 Nov 25 11:48 .gitignore
-rw-r--r-- 1 sekun users   146 Nov 25 15:12 hie.yaml
-rw-r--r-- 1 sekun users  1514 Nov 25 11:26 LICENSE
drwxr-xr-x 2 sekun users  4096 Nov 25 14:29 src
-rw-r--r-- 1 sekun users 13903 Nov 25 14:19 .stylish-haskell.yaml
-rw-r--r-- 1 sekun users  1124 Nov 25 14:48 foo.cabal
drwxr-xr-x 2 sekun users  4096 Nov 25 11:58 test
[sekun@nixos:~/Projects/foo]$ df .
Filesystem                                             1K-blocks     Used Available Use% Mounted on
/dev/disk/by-uuid/c950348d-10f4-421f-a595-486f064fc3f1 471571688 35942640 411601096   9% /

@pepeiborra
Copy link
Collaborator

Could you test with 1.4, to find out in which version things regressed?

@fendor
Copy link
Collaborator

fendor commented Nov 25, 2021

How did you install HLS?

This error looks suspiciously like a bug from implicit-hie-cradle, but no HLS version that uses the buggy version has been published yet.

I just checked that nixpkgs nightly contains the offending version (0.4.0.1). So maybe HLS has been built by nix with implicit-hie-cradle-0.4.0.1?

@sekunho
Copy link
Author

sekunho commented Nov 25, 2021

@pepeiborra Sure, hopefully I'll be able look into it tomorrow if ever needed.

@fendor

How did you install HLS?

Through nix

I just checked that nixpkgs nightly contains the offending version (0.4.0.1). So maybe HLS has been built by nix with implicit-hie-cradle-0.4.0.1?

Ah I think that's it! I just checked it for the specific commit if nixpkgs I'm using; matches the version you mentioned. Is this resolved in 0.4.0.2?

@fendor
Copy link
Collaborator

fendor commented Nov 25, 2021

I hope so, but I don't think implicit-hie has any tests. The relevant PR is: #2342
And it affects you if your cabal version is >= 3.4

@kczulko
Copy link

kczulko commented Nov 27, 2021

Hi,

I've just checked it (I think so...). In my case haskell-language-server-wrapper still fails with implicit-hie-cradle 0.4.0.2. I'm using hls from unstable nixpkgs (1.5.0.0 currently) and I had to turn off testing for hls-tactics-plugin (some ormolu(?) test was failing).

Here is my nix overlay: kczulko/nixos-config@24e4180

And this is what I get:

HLS output (part of it)
Message:  cabal: streamingProcess: chdir: invalid argument (Bad file descriptor)
2021-11-27 01:40:54.183502841 [ThreadId 89] INFO hls:	File:     /home/kczulko/Projects/programming-in-haskell/chapters/Excs1.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message:  cabal: streamingProcess: chdir: invalid argument (Bad file descriptor)
2021-11-27 01:40:54.184112027 [ThreadId 88] INFO hls:	File:     /home/kczulko/Projects/programming-in-haskell/chapters/Excs2.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message:  cabal: streamingProcess: chdir: invalid argument (Bad file descriptor)
2021-11-27 01:40:54.184619315 [ThreadId 90] INFO hls:	File:     /home/kczulko/Projects/programming-in-haskell/app/Main.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError

Thanks,
Karol

@i-koh
Copy link

i-koh commented Nov 29, 2021

Like @sekunho I have the same issue. Here are some further details:

  • macOS 12.0.1 Monterey (with zsh as the shell)
  • VS Code 1.62 (with Haskell extension 1.7.1)
  • GHC 8.10.7 (installed using ghcup)
  • Cabal 3.6.2.0 (installed using ghcup)
  • HLS 1.5.0 (installed using ghcup)

I am not using Nix. I’m new to all this therefore I don’t really know how to debug this (also I can’t run the haskell-language-server command like @sekunho did, because zsh tells me the command wasn’t found).

This doesn’t impose too much of an inconvenience so I think I’ll make use of the compiler directly for now. Hopefully this gets sorted out soon! And yes, thank you all for your work on the HLS!

@Avi-D-coder
Copy link
Collaborator

I have published implicit-hie-cradle-0.5.0.0, which reverts all 0.4's changes.
It should get picked up by nix at some point and this problem will be fixed.

@kczulko
Copy link

kczulko commented Nov 29, 2021

Hi @Avi-D-coder

I'll try to check it and let you know what's the result.

Thank you very much!

Best regards,
Karol

@kczulko
Copy link

kczulko commented Nov 29, 2021

Hi,

Maybe I'm doing sth wrong but updating to implicit-hie-cradle-0.5.0.0 didn't help. Still a lot of cabal: streamingProcess: chdir: invalid argument (Bad file descriptor) errors.

Here's my code: kczulko/nixos-config@8b23423

Best regards,
Karol

@Avi-D-coder
Copy link
Collaborator

Does 0.3.0.5 still work?
The diff between implicit-hie-cradle-0.5.0.0 and implicit-hie-cradle-0.3.0.5 is just the version number.
This issue may be caused by something else.

@kczulko
Copy link

kczulko commented Nov 29, 2021

Nope, still the same error:
cabal: streamingProcess: chdir: invalid argument (Bad file descriptor)

I have also tried nix-build directly from the hls source code at this point:

master origin/master bd0046b7089e32e309f7b29ee6ec1a808ca1db86
Author:     Pepe Iborra <pepeiborra@gmail.com>
AuthorDate: Thu Nov 25 23:21:25 2021 +0000
Commit:     GitHub <noreply@github.com>
CommitDate: Thu Nov 25 23:21:25 2021 +0000

and ofc I get cabal: streamingProcess: chdir: invalid argument (Bad file descriptor).

@Avi-D-coder
Copy link
Collaborator

I'll try and reproduce it.

@kczulko
Copy link

kczulko commented Nov 29, 2021

Oh. I have just spotted how it works... so haskell-language-server-wrapper starts already installed haskell-language-server which is the one that fails for me. So to clarify: haskell-language-server binary build with nix-build cmd works fine for the git
hash I've put in my previous comment (bd0046b7089e32e309f7b29ee6ec1a808ca1db86).

@kczulko
Copy link

kczulko commented Nov 30, 2021

If this helps anyone, that's my workaround for now. I'm building latest (1.5.1.0) hls from sources:

  # hls 1.5.1.0
  haskell-language-server = (import (
    fetchTarball https://github.com/haskell/haskell-language-server/archive/745ef26f406dbdd5e4a538585f8519af9f1ccb09.tar.gz
  )).defaultPackage.x86_64-linux;

Regards,
Karol

@Avi-D-coder
Copy link
Collaborator

I reproduce the cabal: streamingProcess: chdir: invalid argument (Bad file descriptor) error only with implicit-hie-cradle-0.4.0.1 not 0.4.0.2.

@jneira
Copy link
Member

jneira commented Dec 15, 2021

I hope distribution channels will be updated sooner or later with the fixed implicit-hie vuersion, so closing, thanks for reporting the issue!

hagl added a commit to hagl/twentyone that referenced this issue Jan 25, 2022
jerith666 added a commit to jerith666/elbum that referenced this issue Feb 25, 2022
lfborjas added a commit to lfborjas/mercury-haskell-curriculum that referenced this issue Apr 1, 2022
Since upgrading to nixos-21.11 as the channel, LSP refused to work
unless I gave it an hie file:

> haskell-language-server-wrapper --project-ghc-version
No 'hie.yaml' found. Try to discover the project type!

Some clues in some tickets like:
* haskell/haskell-language-server#2398
* haskell/haskell-language-server#1972

But in the end I just added implicit-hie to shell.nix to be able to
run `gen-hie` and then things worked:

> haskell-language-server-wrapper --project-ghc-version
Found "/home/luis/code/lfborjas/haskell-curriculum/hie.yaml" for "/home/luis/code/lfborjas/haskell-curriculum/a"
8.10.7

not sure what that `a` is all about tho.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: implicit-hie os: nixos 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