Setting location for dialyzer PLT in VS Code Elixir LS

I’m running VS Code in a Devcontainer running the Livebook docker image. The Github repo is GitHub - restlessronin/openai_ex: Community maintained OpenAI API Elixir client for Livebook

The Elixir LS extension automatically runs dialyzer but fails with an error message that begins

[Error - 2:25:52 PM] Dialyzer PLT build process exited with reason: 
{{:nocatch, {:dialyzer_error, 
'    The PLT file /home/livebook/.mix/elixir-ls-24.3.4.2_elixir-1.14.2 is not writable'}}

It appears that the MIX_HOME is not writable in the docker image. I have tried setting the output directory using the DIALYZER_PLT env variable, and also the dialyzer key :plt_core_path in the mix.exs. These attempts are not working probably because they’re meant for mix dialyzer run from the terminal.

I can’t find any documentation for how to set this output drectory for elixir-ls.

Does anyone know the answer to this? I imagine developing in the Livebook docker image is going to be more common going forward.

My guess would be, the dializer process is run as the UID:GUID user, configured in de dockerfile. And the initial user used to create the .mix folder is another one (possibly root).
This would turn this into a Unix filepermission problem ( quite common to run into when dealing with docker images)
My (quick) suggestion is to run chmod -R go+rw $MIX_HOME inside the container with root privileges.
A couple of ways to do this come to mind:

  • if sudo is installed you can actually do this from a livebook.
  • using docker (manually) start container, exec into container, run command, exit out of container, docker commit to persist the layer, docker tag to make it yours.
  • using Dockerfile, use FROM current image, and RUN above command, use docker build to make your own image. ( upstream might be willing to add the command to the image)
  • while container is running, use docker exec to enter into it as root… then run the chown.
  • [add another creative way here]

Hope this makes sense, good luck

Thanks @aiko

I submitted this PR to upstream.