JakeBecker/vscode-elixir-ls

File access errors in debug console

KazimirPodolski opened this issue ยท 12 comments

Not sure is it a problem with language server or the plugin, so creating issue in topmost repo.

When I debug mix test I get a couple of errors in debug console:

Started ElixirLS debugger
Elixir version: "1.7.4 (compiled with Erlang/OTP 20)"
Erlang version: "21"
23:21:39.541 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.7.4-1/lib/elixir/lib/collectable.ex. Function: read_file_info. '
23:21:39.542 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.7.4-1/lib/elixir/lib/enum.ex. Function: read_file_info. '
23:21:39.546 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.7.4-1/lib/iex/lib/iex/info.ex. Function: read_file_info. '
23:21:39.546 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.7.4-1/lib/elixir/lib/inspect.ex. Function: read_file_info. '
23:21:39.548 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.7.4-1/lib/elixir/lib/list/chars.ex. Function: read_file_info. '
23:21:39.548 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.7.4-1/lib/elixir/lib/string/chars.ex. Function: read_file_info. '

Then normal test results.

Debug configuration (generated by plugin? I didin't edit it):

{
    "type": "mix_task",
    "name": "mix test",
    "request": "launch",
    "task": "test",
    "taskArgs": [
        "--trace"
    ],
    "startApps": true,
    "projectDir": "${workspaceRoot}",
    "requireFiles": [
        "test/**/test_helper.exs",
        "test/**/*_test.exs"
    ]
}

Everything is working, it's just annoying.

For future reference, I've got through it and it is due to environment variable ERL_LIBS not being set.

I'm using asdf project, and you can add this line to your /etc/environment:
ERL_LIBS="/home/klaus/.asdf/installs/elixir/ref-master/lib/elixir/lib"

I am not sure if this issue is release to this one or elixir-lang/elixir#1278, but I'll post it here.

I am facing the same issue. I've already included the ERL_LIBS variable in both /etc/environment & my .bashrc but keep facing the same problem:

patrick@PATRICK:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic
patrick@PATRICK:~$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
ERL_LIBS="/usr/lib/elixir/lib"
patrick@PATRICK:~$ ls /usr/lib/elixir/lib
eex  elixir  ex_unit  iex  logger  mix
patrick@PATRICK:~$ cat ~/.bashrc | grep ERL_LIBS
export ERL_LIBS="/usr/lib/elixir/lib"
patrick@PATRICK:~$ iex
Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> System.get_env("ERL_LIBS")
"/usr/lib/elixir/lib"

I wouldn't bother too much with it, but distillery started printing warnings during release creation because of that which is somewhat alarming.

For reference, this is my startup trace:

Started ElixirLS debugger
Elixir version: "1.8.2 (compiled with Erlang/OTP 20)"
Erlang version: "22"

21:40:54.356 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.8.2-1/lib/elixir/lib/collectable.ex. Function: read_file_info. '
21:40:54.358 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.8.2-1/lib/elixir/lib/enum.ex. Function: read_file_info. '
21:40:54.360 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.8.2-1/lib/iex/lib/iex/info.ex. Function: read_file_info. '
21:40:54.360 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.8.2-1/lib/elixir/lib/inspect.ex. Function: read_file_info. '
21:40:54.360 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.8.2-1/lib/elixir/lib/list/chars.ex. Function: read_file_info. '
21:40:54.362 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.8.2-1/lib/elixir/lib/string/chars.ex. Function: read_file_info. '
21:40:55.652 [debug] hello world

I just realized that there seems to be an OTP version mismatch. Could it be related(Compiled with 20, running under 22) to this?

bfcns commented

Having the same issue while trying to debug both remote or local:
Started ElixirLS debugger

Elixir version: "1.9.0 (compiled with Erlang/OTP 21)"
Erlang version: "22"

11:55:33.448 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.0-1/lib/elixir/lib/collectable.ex. Function: read_file_info. '

11:55:33.451 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.0-1/lib/elixir/lib/enum.ex. Function: read_file_info. '

11:55:33.453 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.0-1/lib/iex/lib/iex/info.ex. Function: read_file_info. '

11:55:33.453 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.0-1/lib/elixir/lib/inspect.ex. Function: read_file_info. '

11:55:33.456 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.0-1/lib/elixir/lib/list/chars.ex. Function: read_file_info. '

11:55:33.462 [error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.0-1/lib/elixir/lib/string/chars.ex. Function: read_file_info. '
[info] Running AuthenticationWeb.Endpoint with cowboy 2.6.3 at 0.0.0.0:4000 (http)
[info] Access AuthenticationWeb.Endpoint at http://localhost:4000

D4no0 commented

any updates on this issue?

It's usually an indication that VSCode isn't picking up your environment variables.

If running echo $ERL_LIBS on the command line is correct, you can try opening the VSCode from the command line with code .

Alternatively, you could add it directly to your launch config:

{
  "version": "0.2.0",
  "configuration: {
    ...

    "env": {
      "ERL_LIBS": "/path/to/your/erlang/libs",
    }

  }
}

It might also be worth opening the development console from the help menu, and seeing what process.env returns.

Hello @delameko

thanks for this suggestion. Unfortunately this does not seem solve the issue in this case:

If running echo $ERL_LIBS on the command line is correct,

This looks good to me:

patrick@PATRICK:~$ ls -la $(echo $ERL_LIBS)
total 32
drwxr-xr-x 8 root root 4096 Jan 15  2019 .
drwxr-xr-x 4 root root 4096 Jan 15  2019 ..
drwxr-xr-x 3 root root 4096 Jan 15  2019 eex
drwxr-xr-x 3 root root 4096 Jan 15  2019 elixir
drwxr-xr-x 3 root root 4096 Jan 15  2019 ex_unit
drwxr-xr-x 3 root root 4096 Jan 15  2019 iex
drwxr-xr-x 3 root root 4096 Jan 15  2019 logger
drwxr-xr-x 3 root root 4096 Jan 15  2019 mix
patrick@PATRICK:~$ echo $ERL_LIBS
/usr/lib/elixir/lib

you can try opening the VSCode from the command line with code .

Done, I always launch VS Code this way.

Alternatively, you could add it directly to your launch config:

I adjusted my launch.json to this:

{
    // 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",
            "projectDir": "${workspaceRoot}",
            "taskArgs": [
                "--no-halt"
            ],
            "env": {
                "ERL_LIBS": "/usr/lib/elixir/lib",
            }
        },
        {
            "type": "mix_task",
            "name": "mix test",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}",
            "requireFiles": [
                "test/**/test_helper.exs",
                "test/**/*_test.exs"
            ],
            "env": {
                "ERL_LIBS": "/usr/lib/elixir/lib",
            }
        }
    ]
}

It might also be worth opening the development console from the help menu, and seeing what process.env returns.

The VSCode Dev Tools report this:

process.env.ERL_LIBS
"/usr/lib/elixir/lib"

Pressing F5 now to run the application yields the same errors.

I have the exact issue on my Laptop running a fresh install of Ubuntu 18.04 & Elixir 1.9

I was not able to fix the issue by setting the ERL_LIBS environment variable so I tried to trick the solution and it worked.

On Ubuntu 16.04

I downloaded the Elixir Precompiled package

Unpacked it and I created a symlink to the lib folder where the error is saying is expecting to find it.
In my case:
root@pippo:~/deb/elixir_1.9.1-1# pwd
/root/deb/elixir_1.9.1-1
root@pippo:~/deb/elixir_1.9.1-1# ls -l
lrwxrwxrwx 1 root root 22 set 6 16:50 lib -> /home/pippo/elixir/lib

For sure it is not a real solution but it allowed me to use the debugger until the issue is fixed.

@JakeBecker Is there a status on this? This has become a major issue for us as we are unable to debug at all after a somewhat recent plugin update and must rely on "printf debugging" which is very slow and error prone.

I was not able to fix the issue by setting the ERL_LIBS environment variable so I tried to trick the solution and it worked.

On Ubuntu 16.04

I downloaded the Elixir Precompiled package

Unpacked it and I created a symlink to the lib folder where the error is saying is expecting to find it.
In my case:
root@pippo:~/deb/elixir_1.9.1-1# pwd
/root/deb/elixir_1.9.1-1
root@pippo:~/deb/elixir_1.9.1-1# ls -l
lrwxrwxrwx 1 root root 22 set 6 16:50 lib -> /home/pippo/elixir/lib

For sure it is not a real solution but it allowed me to use the debugger until the issue is fixed.

Didn't work for me. Don't know what I did wrong.

root@PlankDebian9:~/deb/elixir_1.9.1-1# ls -al /root/deb/elixir_1.9.1-1/lib/elixir/lib/collectable.ex
-rw-r--r-- 1 pladmin pladmin 4610 Jun 18 02:44 /root/deb/elixir_1.9.1-1/lib/elixir/lib/collectable.ex
root@PlankDebian9:~/deb/elixir_1.9.1-1# 

I am facing the same issue. I am not using asdf or any version manager. Does anyone have a solution ?

Nope, no solution so far.
As a workaround I've resorted to using edbg(https://github.com/etnt/edbg) at work for Erlang code.

Not tried it with Elixir so far though.

This project has moved!

It's now being maintained by proactive volunteers from the Elixir community over at elixir-lsp/vscode-elixir-ls. The main ElixirLS codebase is now at elixir-lsp/elixir-ls. Updates will continue to be published from that repo to the original VS Code extension, so no need to switch plugins.

To avoid inundating the new maintainers with issues, please verify that your issue persists with the latest version of the extension (which is published from the new repo) before re-filing your issue there.

Thanks for using ElixirLS!