akoutmos / doctor

Ensure that your Elixir project documentation is healthy
MIT License
180 stars 15 forks source link

`(File.Error) could not read file` when developing with docker #16

Closed samm81 closed 4 years ago

samm81 commented 4 years ago

I do my development inside a docker container. Sometimes, but not always, when I mix doctor inside the container Doctor seems to try and open files using the host's paths rather than the container's paths.

% docker exec -it container-name mix doctor
Doctor file found. Loading configuration.

21:53:45.509 [error] Task #PID<0.92.0> started from #PID<0.222.0> terminating
** (File.Error) could not read file "/home/###/workspace/###/lib/###/accounts/credential.ex": no such file or directory
    (elixir 1.10.1) lib/file.ex:353: File.read!/1
    lib/module_information.ex:39: Doctor.ModuleInformation.load_file_ast/1
    lib/cli/cli.ex:48: anonymous fn/1 in Doctor.CLI.async_fetch_user_defined_functions/1
    (elixir 1.10.1) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.10.1) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<0.104002830/0 in Doctor.CLI.async_fetch_user_defined_functions/1>
    Args: []
** (EXIT from #PID<0.92.0>) an exception was raised:
    ** (File.Error) could not read file "/home/###/workspace/###/lib/###/accounts/credential.ex": no such file or directory
        (elixir 1.10.1) lib/file.ex:353: File.read!/1
        lib/module_information.ex:39: Doctor.ModuleInformation.load_file_ast/1
        lib/cli/cli.ex:48: anonymous fn/1 in Doctor.CLI.async_fetch_user_defined_functions/1
        (elixir 1.10.1) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
        (elixir 1.10.1) lib/task/supervised.ex:35: Task.Supervised.reply/5
        (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

/home/###/workspace/###/lib/###/accounts/credential.ex is the path on the host, not in the container.

samm81 commented 4 years ago

Also, mix clean followed by mix compile in the docker environment solves this issue. This might have something to do with the fact that I use a language server (which will compile files on my host computer), and then run mix doctor in the container.

akoutmos commented 4 years ago

Hrmm. I'm not coming up with anything as far as theories goes to try and understand what's going on exactly. If it wouldn't be too much to ask, could you set up a sample GitHub repo that reproduces the error? Is it perhaps an issue with the Docker Compose volume mounts?

akoutmos commented 4 years ago

Closing this issue for now as I was not able to reproduce. Feel free to reach out again if you come across any issues and can provide repro steps. Thanks!