0

I found the vscode's elixir-ls version is 0.11.0, which is ElixirLS compiled with Elixir 1.11.4 and erlang 22.

The local erlang and elixir version is

macbook:~ yuchen$ cat .tool-versions
erlang 24.3.4.6
elixir 1.14.1-otp-24

One of deps application is iconv, which is compiled in the local erlang(24.3.4.6) and elixir(1.14.1-otp-24) .

When phoenix start up in vscode by debug mode, the error message is as follows:

ElixirLS compiled with Elixir 1.11.4 and erlang 22

[error] failed to load NIF /Users/yuchen/Documents/Project/CY2/mirror/_build/dev/lib/iconv/priv/lib/iconv: load_nif/2 must be explicitly called from the NIF module. It cannot be called through apply/3.

I have already exclude the nif module in the launch.json file, which is as follows:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "mix_task",
            "name": "mix (Default task)",
            "request": "launch",
            "task": "phx.server",
            "projectDir": "${workspaceRoot}",
            "excludeModules": [
                ":iconv_app"
                // ":pc",
                // ":pc_compilation",
                // ":pc_port_env",
                // ":pc_port_specs",
                // ":pc_prv_clean",
                // ":pc_prv_compile",
                // ":pc_util"
            ]
        },
        {
            "type": "mix_task",
            "name": "mix test",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace",
                "--warnings-as-errors",
                "--only",
                "external"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}",
            "requireFiles": [
                "test/**/test_helper.exs",
                "test/**/*_test.exs"
            ]
        }
    ]
}

When mix test, no error message appears.

I found there are 3 projects are related to elixir-ls. enter image description here.

Which one is related to this problem and should be compiled locally?

In addition, is it necessary to recompile elixir-ls for solving nif problem?

Chen Yu
  • 3,955
  • 1
  • 24
  • 51
  • elixir-ls is the language server responsible for compilation and understanding of elixir code, as far as I know, elixir-ls should use the versions specified in .tools-versions: https://github.com/elixir-lsp/elixir-ls#supported-versions – Daniel Oct 24 '22 at 08:54
  • I have read the doc already, The autodection has not solved the problem. Maybe it is related to the elixir-ls the created compiled base (elixir, erlang) version. Because the elixir-ls switch is not easy, so I have posted the above question. – Chen Yu Oct 24 '22 at 21:10

0 Answers0