slashmili/alchemist.vim

Alchemist not finding 3rd-party modules in project

mwdiers opened this issue · 6 comments

elixir-sense is unable to find any installed and compiled dependencies, causing Alchemist to break.

If an installed dependency is referenced in a use statement, because elixir-sense cannot find it, autocomplete fails to query elixir-sense at all, and Alchemist breaks even for kernel modules.

For example, the following error is displayed as I attempt to type use Plug.Router:

alchemist.vim: failed with message error:/Users/xxxx/.config/nvim/plugged/alchemist.vim/elixir_sense/lib/elixir_sense/core/ast.ex:19: module Plug.R is not loaded and could not be found
Press ENTER or type command to continue

Elixir: 1.6.4

OTP: 20

Python: 2.7.14

Neovim 0.2.2

  1. Which plugin are you using:

[ ] basic omnifunc
[X] YouCompleteMe
[ ] deoplete

  1. Which steps of Debugging passed?

[X] Elixir Module definition
[X] Elixir Function definition
[X] Elixir Module/Function docs
[X] Your Project Module definition
[X] Your Project Function definition

  1. Do you have a specific setup? macOS 10.13.4, everything installed with Homebrew

log.log

init.vim.txt

Updated description as I researched this further. I am running nvim from the root of the project.

I also tested with deoplete, and have the same problem, except that it doesn't error as I am trying type the name of a sub-module, but auto-complete still breaks.

I am still trying to track this down, and it is an extremely bizarre problem.

If I have ANY project in this exact path: ~/Devel/elixir/ToDo/ then Alchemist cannot find any dependencies in the project.

I tested this with the simplest possible use case. I removed all other projects from the above directory. I made a new mix project called apptest in the above directory. The full project path is: ~/Devel/elixir/ToDo/apptest . I add lib/apptest.ex to the project containing:

defmodule Apptest do
  def test do
    :ok
  end
end

I add Plug as a dependency to mix.exs . I run mix deps.get && mix compile . I then edit lib/apptest.ex and attempt to test auto-complete on the Plug module. The problem occurs.

If I change any single character, or add any character to any directory in the path ~/Devel/elixir/ToDo and restart nvim, the problem goes away and Alchemist works correctly.

I got nothin'.

There does appear to be a separate YCM issue that happens regardless of the above path issue. Namely, when typing a use statement that references a sub-module, elixir-sense errors out while trying to type the name of the sub-module. So when typing use Plug.Router I get an error the moment I type a capital R. However, after the name is entered, autocomplete still works. Deoplete does not have this problem.

Additional troubleshooting steps:

  • Uninstalled and cleaned all elixir and erlang versions from Homebrew
  • Verified no other elixir/erlang dependencies were installed.
  • Reinstalled elixir/erlang
  • ran chown -R xxxx:staff ~/Devel && chmod -R u+rwX ~/Devel

It's worth noting that my Homebrew prefix is /opt/homebrew. I doubt that matters.

@mwdiers I also got the same result when I forced autocomplete after typing

use Plug.R<C-x><C-o>

It's something that I guess we need to fix in elixir-sense, to avoid looking the module in this case.

But in meanwhile is there anything we can do here? When you see the error, is the autocomplete broken until exit and start vim? One possible way is to avoid triggering error in this case ...

@slashmili Aside from the bizarre path issue noted above (where no dependency modules can be found at all), autocomplete is only broken if ause macro is referring to a module that elixir-sense cannot find.

This is true also while typing the name of the submodule. However, as soon as I finish typing the name (which can be challenging because of the error coming up on every letter) and the use macro is referring to a valid module, auto-complete starts working again.

Note, that this is not a problem while typing a name anywhere else. Only while typing the use statement.

I close this issue for now