-
Notifications
You must be signed in to change notification settings - Fork 207
HIE doesn't work after build. "haskell-lsp: Failed to parse message header" error #1499
Comments
Thank you for the detailed bug report! EDIT: One last thing, does the project build with just |
Also, make sure you are using current master, for a while we had a version that errored if it received the |
@fendor Thanks for your prompt explanation! >$ tree test/
test/
├── ChangeLog.md
├── LICENSE
├── README.md
├── Setup.hs
├── app
│ └── Main.hs
├── package.yaml
├── src
│ └── Lib.hs
├── stack.yaml
├── test
│ └── Spec.hs
└── test.cabal
3 directories, 10 files Precisely, the following script can reproduce my problem on my computer: #!/usr/bin/env bash
cd $(mktemp -d)
stack new test
cd test
code . # open this directory in VS Code If I open any one of the files |
@alanz Yes, I'm using the current master. I git-cloned it and built it yesterday. |
This is the log file of the VS Code extension: |
Opening You are using the implicit cradle discovery mechanism, also called, cabal-helper. This mechanism has a bug: mpickering#47. #!/usr/bin/env bash
cd $(mktemp -d)
stack new test
cd test
stack build # initial build
code . # open this directory in VS Code then open |
@fendor Thank you! I have just tried the commands. However, the problem persists. EDIT: If I open |
Can you show the log? E.g. press |
I removed all the symlinks for GHC 8.8.1 from $PATH and substituted them with symlinks for GHC 8.6.5. However, the problem is still there. The following are the logs.
|
And |
$> stack build
test> configure (lib + exe)
Configuring test-0.1.0.0...
test> build (lib + exe)
Preprocessing library for test-0.1.0.0..
Building library for test-0.1.0.0..
Preprocessing executable 'test-exe' for test-0.1.0.0..
Building executable 'test-exe' for test-0.1.0.0..
[2 of 2] Compiling Main
Linking .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/test-exe/test-exe ...
test> copy/register
Installing library in /private/var/folders/pr/x9vb6yhj0wz0dsfy1s6_6nh80000gn/T/tmp.B8OT1LWl/test/.stack-work/install/x86_64-osx/0baa6054dad47a08f0e811fc873921f837a750d427b358a66f338688f7da9445/8.6.5/lib/x86_64-osx-ghc-8.6.5/test-0.1.0.0-GonkJTtOuP1BV3CgSh86TE
Installing executable test-exe in /private/var/folders/pr/x9vb6yhj0wz0dsfy1s6_6nh80000gn/T/tmp.B8OT1LWl/test/.stack-work/install/x86_64-osx/0baa6054dad47a08f0e811fc873921f837a750d427b358a66f338688f7da9445/8.6.5/bin
Registering library for test-0.1.0.0..
$> stack exec test-exe
someFunc
$> tree .stack-work/
.stack-work/
├── cabal-helper
│ ├── CabalHelper
│ │ ├── Runtime
│ │ │ ├── Compat.hi
│ │ │ ├── Compat.hs
│ │ │ ├── Compat.o
│ │ │ ├── HelperMain.hi
│ │ │ ├── HelperMain.hs
│ │ │ ├── HelperMain.o
│ │ │ └── Main.hs
│ │ └── Shared
│ │ ├── Common.hi
│ │ ├── Common.hs
│ │ ├── Common.o
│ │ ├── InterfaceTypes.hi
│ │ ├── InterfaceTypes.hs
│ │ └── InterfaceTypes.o
│ ├── Main.hi
│ ├── Main.o
│ └── cabal-helper
├── dist
│ └── x86_64-osx
│ └── Cabal-2.4.0.1
│ ├── build
│ │ ├── Lib.dyn_hi
│ │ ├── Lib.dyn_o
│ │ ├── Lib.hi
│ │ ├── Lib.o
│ │ ├── Paths_test.dyn_hi
│ │ ├── Paths_test.dyn_o
│ │ ├── Paths_test.hi
│ │ ├── Paths_test.o
│ │ ├── autogen
│ │ │ ├── Paths_test.hs
│ │ │ └── cabal_macros.h
│ │ ├── libHStest-0.1.0.0-GonkJTtOuP1BV3CgSh86TE-ghc8.6.5.dylib
│ │ ├── libHStest-0.1.0.0-GonkJTtOuP1BV3CgSh86TE.a
│ │ └── test-exe
│ │ ├── autogen
│ │ │ ├── Paths_test.hs
│ │ │ └── cabal_macros.h
│ │ ├── test-exe
│ │ └── test-exe-tmp
│ │ ├── Main.hi
│ │ ├── Main.o
│ │ ├── Paths_test.hi
│ │ └── Paths_test.o
│ ├── build-lock
│ ├── package.conf.inplace
│ │ ├── package.cache
│ │ ├── package.cache.lock
│ │ └── test-0.1.0.0-GonkJTtOuP1BV3CgSh86TE.conf
│ ├── setup-config
│ ├── stack-build-caches
│ │ └── 0baa6054dad47a08f0e811fc873921f837a750d427b358a66f338688f7da9445
│ │ ├── exe-test-exe
│ │ └── lib
│ └── stack-cabal-mod
├── install
│ └── x86_64-osx
│ ├── 0baa6054dad47a08f0e811fc873921f837a750d427b358a66f338688f7da9445
│ │ └── 8.6.5
│ │ ├── bin
│ │ │ └── test-exe
│ │ ├── doc
│ │ │ └── test-0.1.0.0
│ │ │ └── LICENSE
│ │ ├── lib
│ │ │ └── x86_64-osx-ghc-8.6.5
│ │ │ ├── libHStest-0.1.0.0-GonkJTtOuP1BV3CgSh86TE-ghc8.6.5.dylib
│ │ │ └── test-0.1.0.0-GonkJTtOuP1BV3CgSh86TE
│ │ │ ├── Lib.dyn_hi
│ │ │ ├── Lib.hi
│ │ │ ├── Paths_test.dyn_hi
│ │ │ ├── Paths_test.hi
│ │ │ └── libHStest-0.1.0.0-GonkJTtOuP1BV3CgSh86TE.a
│ │ └── pkgdb
│ │ ├── package.cache
│ │ ├── package.cache.lock
│ │ └── test-0.1.0.0-GonkJTtOuP1BV3CgSh86TE.conf
│ └── 0c1dd042ce02da0af185d878b7827c29b01da878f4edcd00b6a40a16dfe3e861
│ └── 8.6.5
│ └── pkgdb
│ ├── package.cache
│ └── package.cache.lock
├── stack.sqlite3
└── stack.sqlite3.pantry-write-lock
29 directories, 58 files
$> stack clean
$> tree .stack-work/
.stack-work/
├── cabal-helper
│ ├── CabalHelper
│ │ ├── Runtime
│ │ │ ├── Compat.hi
│ │ │ ├── Compat.hs
│ │ │ ├── Compat.o
│ │ │ ├── HelperMain.hi
│ │ │ ├── HelperMain.hs
│ │ │ ├── HelperMain.o
│ │ │ └── Main.hs
│ │ └── Shared
│ │ ├── Common.hi
│ │ ├── Common.hs
│ │ ├── Common.o
│ │ ├── InterfaceTypes.hi
│ │ ├── InterfaceTypes.hs
│ │ └── InterfaceTypes.o
│ ├── Main.hi
│ ├── Main.o
│ └── cabal-helper
├── install
│ └── x86_64-osx
│ ├── 0baa6054dad47a08f0e811fc873921f837a750d427b358a66f338688f7da9445
│ │ └── 8.6.5
│ │ ├── bin
│ │ │ └── test-exe
│ │ ├── doc
│ │ │ └── test-0.1.0.0
│ │ │ └── LICENSE
│ │ ├── lib
│ │ │ └── x86_64-osx-ghc-8.6.5
│ │ │ ├── libHStest-0.1.0.0-GonkJTtOuP1BV3CgSh86TE-ghc8.6.5.dylib
│ │ │ └── test-0.1.0.0-GonkJTtOuP1BV3CgSh86TE
│ │ │ ├── Lib.dyn_hi
│ │ │ ├── Lib.hi
│ │ │ ├── Paths_test.dyn_hi
│ │ │ ├── Paths_test.hi
│ │ │ └── libHStest-0.1.0.0-GonkJTtOuP1BV3CgSh86TE.a
│ │ └── pkgdb
│ │ ├── package.cache
│ │ ├── package.cache.lock
│ │ └── test-0.1.0.0-GonkJTtOuP1BV3CgSh86TE.conf
│ └── 0c1dd042ce02da0af185d878b7827c29b01da878f4edcd00b6a40a16dfe3e861
│ └── 8.6.5
│ └── pkgdb
│ ├── package.cache
│ └── package.cache.lock
├── stack.sqlite3
└── stack.sqlite3.pantry-write-lock
18 directories, 31 files |
OK, can you try adding a file cradle:
stack: Does that work? |
@fendor Yes, now it works well! Thank you very much! |
Glad to hear that but you are not off-the-hook yet! We still have to find out why it doesnt work out-of-the-box. To extend your configuration, see https://github.com/haskell/haskell-ide-engine#project-configuration |
I appreciate your efforts! I will continue watching this issue. Please let me know if there's anything that I can help with. |
So, I did some investigating and I am able to reproduce the issue with the following steps: stack new test
cd test/
code . Make sure to only open If you only open @mingcenwei Can you verify similar behaviour? I discussed this with @flutterlice and we have different observations regarding the next step. For me, explicitly building the project, e.g.: rm -rf .stack_work/
stack build
code . Makes every component work as expected. However, for @flutterlice, the issue seemed fixed at first, but after typing, the errors were shown again. @mingcenwei I think you tried However, adding a custom cradle:
stack: Fixes it for all of us, iirc. I think this issue is only cabal-helper related, e.g. not enough files are generated for dependencies, e.g. we might run into haskell/cabal#2209 or maybe commercialhaskell/stack#2790. |
@fendor I found that the error message will be triggered on my MacBook no matter which file I open (even if I only open |
@mingcenwei are you opening this project from a temporary directory? I just noticed
Not that it shouldn't work, but I think we had another user with issues when they tried to open a project inside a temporary directory? cc @fendor |
@mingcenwei The plot thickens. Would you mind trying if cabal is able to build the project correctly?
Or stack new test
cd test
echo "packages: ./" > cabal.project
## now make sure that your `ghc` on the path has the same version
## as the version `hie` has been compiled with
code . # check the files, report errors, etc..
cabal v2-build all # build the project
code . # compare results again |
@bubba The problem still exists even if I put the project into @fendor If I add the |
uhm... weird... In the terminal of vscode, can you check if vscode really knows about ghc? |
@fendor Oh, my fault. I added the directory of |
Ok, so, we are closing in, the issue only happens with cabal-helper with stack. |
I attempted to build HIE with stack from source on my macOS Catalina. The executables were successfully installed to
~/.local/bin
. However, whenever I runhie
(orhie-wrapper
), the program will block after displaying the line2019-12-XX XX:XX:XX.XXXXXX [ThreadId 4] - args:[]
. Then if I press any key, the program will crash (and printhie-wrapper: callProcess: /Users/say/.local/bin/hie-8.6.5 (exit 1): failed
if I usehie-wrapper
rather thanhie
). If I add the flags--lsp --debug
, the program will block after displaying the linehaskell-lsp:Starting up server ...
, and crash if I press any key and print the message:2019-12-26 01:28:33.947057 [ThreadId 4] - haskell-lsp: Failed to parse message header: : string exiting 1 ...
(^ The program gets stuck.)
(^ It crashes if I press any key.)
The Haskell Language Server extension on Visual Studio Code doesn't work, either. It's continually emitting the following error messages:
The following are the last few lines written to the standard output after I run
stack repl haskell-ide-engine
in the build directory:Environment:
The text was updated successfully, but these errors were encountered: