Closed RobertoSchneiders closed 11 months ago
Create a devcontainer with a dockerfile that setups elixir. Run VSCode in dev container and install the extension. It’s fully working in that setup
@lukaszsamson I can see how that would work but it's not an ideal setup for me since running VSCode inside the container has some limitations. some that come to mind are:
I'm not sure but I think people trying to use coder.com or GitHub codespaces would have similar limitations and would benefit from being able to run the language server inside a container.
Why would you need VSCode inside container? Please use standard devcontainers feature https://code.visualstudio.com/docs/devcontainers/containers
This issue has example devcontainer setup https://github.com/elixir-lsp/vscode-elixir-ls/issues/313#issuecomment-1509993436
as far as I understand, using a dev container is basically the same as running a VSCode Server inside the container so all the drawbacks I mentioned above still apply but maybe I'm missing something. It feels like I will be limited in the context of that container for that VSCode session.
As an example, If I try to connect to the Elixir container using the dev container feature, the terminal is now limited to that container and I can't access anything from the host. My ZSH terminal is simply not there, seems like I would have to configure that again for each of the containers I want to access. I can't manage my docker services that are running in the host, let's say I want to restart/change some of the other containers/services (e.g. Postgres). If I want to switch to a different repository where I have a ruby project, it would involve opening additional instances of VSCode.
The main advantage of having a VSCode Server running in the host and only the services running in Docker containers is that you can manage everything from one VSCode instance, you can use the Docker extensions, and use one ZSH configuration for multiple projects. The configuration to run Tailscale funnels (in case you wanna make one of the services briefly publicly available) is easier done in the host instead of each of the development containers.
as far as I understand, using a dev container is basically the same as running a VSCode Server inside the container
I don't know how it works under the hood but you are right judging from
As an example, If I try to connect to the Elixir container using the dev container feature, the terminal is now limited to that container and I can't access anything from the host
Terminal in devcontainer runs in the container. So you need to install everything you need there. You can access host via docker network. I have not tried it but I guess you can mount your zshrc, home dir, /etc/passwd /etc/shadow, docker unix domain socket and whatnot as docker volumes
I wouldn't be able to start/stop new containers or manage my other containers from VSCode
If you mount docker unix domain socket you can run docker in docker
As for the extension and language server, the extension runs language server and debugger as processes. It communicates with them via stdin/stdout using binary protocol https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#headerPart and https://microsoft.github.io/debug-adapter-protocol/overview. While LSP allows TCP as well, this is not implemented in elixir-ls. If you want to run it in container there are 2 ways I can think of.
By default the extension launches language_server.sh
or debugger.sh
from extension install dir. You can override the directory with elixirLS.languageServerOverridePath
setting
@lukaszsamson awesome, I will give it a try.
In order to replace the commands that currently execute the language_server.sh
and debugger.sh
scripts, do you think it's enough to change the buildCommand function or is there somewhere else that needs to be changed?
That would be sufficient I think
awesome, thank you very much @lukaszsamson
I'm new to Elixir and LSP language servers. I have a fully dockerized setup, meaning that the host that runs VSCode (VSCode server in my case) doesn't have Elixir, everything runs inside docker containers. I used other language servers in development environments like this in the past but none were LSP.
I can run the language server inside the container, I can also run elixir/mix commands from the host by just relaying them to the container, I just can't make the VSCode extension work with that.
I saw a few comments saying it was not supported and that I needed Elixir/Erlang to be installed in the host. If that is the case, can someone help me understand what are the limitations? maybe I can help tackle some of them.
The main questions I have right now are:
Environment