haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

STDIN not piped when wrapping hls in docker #2045

Closed aschmois closed 9 months ago

aschmois commented 3 years ago

We have a docker image that contains HLS and prebuilt dependencies. I thought it would be nice to add HLS to this image and have the extension run a script that wraps around it. HLS will run but it looks like stdin is completely ignored. I tried a few different ways with docker-compose -T and docker -i but nothing seems to pipe stdin correctly. Maybe I'm setting this up wrong, or maybe vscode's stdin transport just doesn't support doing this.

This is the wrapping script I built, it's pretty simple. stack is the name of the docker compose container and it's just ubuntu with stack, some prebuilt dependencies, and hls.

#!/usr/bin/env bash
docker-compose up -d stack
# exec docker-compose exec -T stack haskell-language-server-wrapper "$@"
exec docker exec -i "$(docker-compose ps -q stack)" haskell-language-server-wrapper "$@"

The ouput generates as expected, but nothing is piped in so the extension just doesn't work:

[client] run command: "/home/user/projects/example/tools/haskell-language-server-wrapper --lsp"
[client] debug command: "/home/user/projects/example/tools/haskell-language-server-wrapper --lsp"
[client] server cwd: undefined
example_stack_1 is up-to-date
Found "/home/user/projects/example/hie.yaml" for "/home/user/projects/example/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.2.0.0, Git revision be2071e985cb417f984ab00a1aad76dee02d6d0b (dirty) x86_64 ghc-8.10.4
Current directory: /home/user/projects/example
Operating system: linux
Arguments: ["--lsp"]
Cradle directory: /home/user/projects/example
Cradle type: Stack

Tool versions found on the $PATH
cabal:      Not found
stack:      2.7.1
ghc:        Not found

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"]
Launching haskell-language-server exe at:/usr/bin/haskell-language-server-8.10.4
haskell-language-server version: 1.2.0.0 (GHC: 8.10.4) (PATH: /usr/bin/haskell-language-server-8.10.4) (GIT hash: be2071e985cb417f984ab00a1aad76dee02d6d0b)
Starting (haskell-language-server)LSP server...
  with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",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/user/projects/example
 Starting LSP server...
If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
jneira commented 3 years ago

Hi, thanks for the bug report and sorry for the late triage. I hope such a environment has been working before but i am not using docker myself. haskell has an official image in ms: https://github.com/microsoft/vscode-dev-containers/tree/fecdec6718bc6003ad309989b976c373327ab3dc/containers/haskell maybe does it worth give it a try?

aschmois commented 3 years ago

I ran docker-compose run instead of executing a running container and it now accepts stdio, it's not the best solution but it works. There's different ways to communicate with vscode lsps, I think the most common way that doesn't rely on stdio, is ipc. Do you know if it would be possible to convert to it? I can attempt a PR if you think it's possible.

michaelpj commented 9 months ago

Closing as old and quiet