Open donut opened 5 years ago
Hmm yeah that's a tricky one. reason-language-server needs to be able to communicate with esy to determine the location of ocamlc & other binaries used for on-the-fly compilation, and to read the compiler artifacts for analysis. The only solution I could imagine would be having the reason-language-server be located in the docker container, and have the editor extension run it in there. Having a setup like this would also unlock WSL compatibility, which some people have asked for (#114).
To try out this proof of concept, you could have something like the following:
docker-compose exec <container-name> ~/path/to/rls.exe
reason_language_server.location
to that shell script.And I think that might work? Let me know how it goes :)
Unfortunately, that didn't work. I'm getting this error:
the input device is not a TTY [Info - 8:25:21 AM] Connection to server got closed. Server will restart
I used the linux.zip file from the releases page and placed the exe at [/reason-language-server/rls.exe] in the container. The bash script used (rls.exe):
#!/bin/bash
export $(grep -v ^# /Users/donut/RTM/OVPSync/.env | xargs -0)
docker-compose --file="/Users/donut/RTM/OVPSync/docker-compose.yml" exec dev \
/reason-language-server/rls.exe "$@"
Then I set reason_language_server.location
to rls.exe
in the Workspace Settings. I put the bash script in the project's root.
The Dockerfile:
ARG ESY_IMAGE
FROM $ESY_IMAGE as esy
# Niceties
RUN apk add --no-cache fish vim
# Timezone
# See https://serverfault.com/q/683605/54523
ARG TZ
RUN apk add --no-cache tzdata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Needed for @esy-ocaml/libffi@3.2.10
RUN apk add --no-cache texinfo
# Needed for @opam/tls
RUN apk add --no-cache gmp-dev
# Need for @opam/caqti-driver-mariadb
RUN apk add --no-cache mariadb-dev
# Reason language server
# Used by VSCode through `docker-compose exec` to get the right environment.
RUN apk add --no-cache unzip
RUN mkdir /reason-language-server
WORKDIR /reason-language-server
RUN curl -LO https://github.com/jaredly/reason-language-server/releases/download/1.5.2/linux.zip
RUN unzip linux.zip
RUN rm linux.zip
RUN mv reason-language-server/reason-language-server.exe rls.exe
RUN rmdir reason-language-server
RUN apk del --no-cache unzip
RUN mkdir /app
WORKDIR /app
ENTRYPOINT ["tail", "-f", "/dev/null"]
On the host, in the project's directory, running using the bash script:
[I] ~/RTM/OVPSync (dockerificiation *$%)
↪ ./rls.exe --help 0@08:51:37
🎉 Reason Language Server 🎉
Usage: run without arguments, and communicate over stdin/stdout,
following the language server protocol as defined in
https://microsoft.github.io/language-server-protocol/specification
Logs are stored in `<project_root>/node_modules/.lsp/debug.log`.
Looks like the Input device is not a TTY
error is coming from docker. (see this SO answer https://stackoverflow.com/a/43099210/290784)
I assume docker-compose
passes in -t
automatically.
Here's an issue on the compose repo from a year ago https://github.com/docker/compose/issues/5696 that suggests putting export COMPOSE_INTERACTIVE_NO_CLI=1
in your bash script ... and you might also need the -T
flag in your docker compose command.
Progress, I think.
With just adding -T
, I got this new error:
Setting log location: /Users/donut/RTM/OVPSync/node_modules/.lsp/debug.log
[Error - 3:06:14 PM] Request textDocument/documentSymbol failed.
Message: No root directory found
Code: -32603
[Error - 3:06:21 PM] Request textDocument/documentHighlight failed.
Message: No root directory found
Code: -32603
[Error - 3:06:22 PM] Request textDocument/codeAction failed.
Message: No root directory found
Code: -32603
If I include export COMPOSE_INTERACTIVE_NO_CLI=1
, I get no error messages or any output for Reason Language Server, but also nothing works for .ml files except syntax highlighting. This happens regardless of the -T
flag's presence.
Here's the updated shell script:
#!/bin/bash
export $(grep -v '^#' /Users/donut/RTM/OVPSync/.env | xargs -0)
docker-compose --file="/Users/donut/RTM/OVPSync/docker-compose.yml" \
exec -T --workdir=/app app /reason-language-server/rls.exe $@
The Dockerfile hasn't changed in any ways relevant to this.
Very cool. Ok yeah so the next issue is helping rls translate between the directory paths that vscode is sending (which are in the host fs) and the ones that it can access (in the docker image). I imagine this would want to be done as an argument to rls in the bash script. I don't have a ton of bandwidth to implement this at the moment, but if you're interested I could give you pointers!
Yeah, I'm interested! If you can point me in the right direction, I'll take a look on Monday.
I have my
esy
environment setup in a docker container. I do not have it installed on the host machine. I usedocker-compose exec <container name> esy
. But I keep getting this error: "Couldn't get esy version".The solution I found is to install
esy
on the host machine and build there and on the docker container. This isn't ideal, but it's working for now..Unfortunately, this basically blocks all useful functionality.
debug log