Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected compiler response: {:error, %CompileError{...}} #284

Closed
petermueller opened this issue Oct 12, 2023 · 11 comments
Closed

Unexpected compiler response: {:error, %CompileError{...}} #284

petermueller opened this issue Oct 12, 2023 · 11 comments

Comments

@petermueller
Copy link

petermueller commented Oct 12, 2023

NextLS Version: 0.13.4, from brew
Transport: TCP
Editor + Version: VSCode, 1.83.1
Elixir Version: 1.13.4 (set globally w/ ASDF as 1.13.4-otp-25)
Erlang/OTP Version: 25.2.3 (set globally w/ ASDF as 25.2.3)
macOS Version + arch: 13.5.2 (Ventura), Intel x86

I'm seeing a compile error related to a private repo dep we have when I open an elixir file for our application

From the logs it seems like it's not because it's private, but just that it's the first dep that is being compiled.

Above the error listed below, I'm seeing tons of run mix deps.get style warnings for standard hex.pm hosted packages too, and I'm positive that my deps are pulled down for the proper version.

I'm also seeing the typical "(Mix) Can't continue due to errors on dependencies", followed by a node down crash

I'm starting vscode from the command line, and have confirmed that asdf is setting Elixir to the same version as my asdf local, just in case maybe nextls was calling elixir from its own directory, or the directory I was running it in (same as the app), and potentially getting missing deps.

[NextLS] ==> my_priv_gh_repo
Error while loading project :my_priv_gh_repo at /Users/peter/code/my_app/deps/my_priv_gh_repo
[Trace - 10:46:51 AM] Received notification 'window/logMessage'.
[Warn  - 10:46:51 AM] [NextLS] Unexpected compiler response: {:error, %CompileError{file: "/Users/peter/code/my_app/deps/my_priv_gh_repo/mix.exs", line: 1, description: "cannot define module MyPrivGhRepo.MixProject because it is currently being defined in /Users/peter/code/my_app/deps/my_priv_gh_repo/mix.exs:1"}}
[Trace - 10:46:51 AM] Received notification '$/progress'.

after enabling verbose, clearing ./.elixir-tools/ and rerunning a little later:

[NextLS] Error while loading project :my_priv_gh_repo at /Users/peter/code/my_app/deps/my_priv_gh_repo
[Trace - 11:41:49 AM] Received notification 'window/logMessage'.
Params: {
    "message": "[NextLS] Unexpected compiler response: {:error, %CompileError{file: \"/Users/peter/code/my_app/deps/my_priv_gh_repo/mix.exs\", line: 1, description: \"cannot define module MyPrivGhRepo.MixProject because it is currently being defined in /Users/peter/code/my_app/deps/my_priv_gh_repo/mix.exs:1\"}}",
    "type": 2
}

If I switch to 1.14+ for asdf global and load up fresh phx.new everything seems to work fine.

@mhanberg
Copy link
Collaborator

I'm on vacation right now by I'll take a look next week when I get back 👍

Thanks for the detailed bug report!

Can you include OTP and macOS version as well tho?

@petermueller
Copy link
Author

@mhanberg thanks for the quick reply. Enjoy your vacation :)

I updated the original description, but have quick parsing it's:
Erlang/OTP Version: 25.2.3 (set globally w/ ASDF as 25.2.3)
macOS Version + arch: 13.5.2 (Ventura), Intel x86

Once you're back and have time, let me know if you need debugging help, or if a public repo replicating it would help.

@mhanberg
Copy link
Collaborator

Public repo reproducing the issue is always helpful!

See you next week 😎

@mhanberg
Copy link
Collaborator

I'm back from vacation, will hopefully take a look umbrella app in Zed this week.

If you do get time tho, a repro would be helpful, but now worries if you're busy

@mhanberg
Copy link
Collaborator

I'm back from vacation, will hopefully take a look umbrella app in Zed this week.

I think I got my wires crossed with a different issue 😅

@slashmili
Copy link

slashmili commented Dec 4, 2023

I'm seeing the same error, not sure if it's related or I should create another issue?

Transport: stdio
macOS Version: 14.1 (23B74)

$ nextls  --version
0.15.0
$ nvim --version
NVIM v0.9.4
$ cat .tool-versions
elixir 1.15.7-otp-26
erlang 26.1.2

I'm using nvim-lspconfig directly:

      require'lspconfig'.elixirls.setup{
           cmd = {'/usr/local/bin/nextls', '--stdio'}
      }

LspInfo log:

[START][2023-12-04 09:39:11] LSP logging initiated
[WARN][2023-12-04 09:39:11] ...lsp/handlers.lua:537	'[NextLS] Unexpected compiler response: {:error, %CompileError{file: "/Users/milad/my_app/mix.exs", line: 0, description: "cannot compile module MyApp.MixProject (errors have been logged)"}}'
[START][2023-12-04 09:41:55] LSP logging initiated
[WARN][2023-12-04 09:41:55] ...lsp/handlers.lua:537	"[NextLS] Unexpected compiler response: {:error, %{message: \"Can't continue due to errors on dependencies\", __struct__: Mix.Error, __exception__: true, mix: 1}}"

Update:
I also configured next-ls in zed and seems like when I run /usr/local/bin/nextls it somehow triggers epmd on wrong next-ls 🤔

pgrep -fl epmd
76585 /Users/milad/Library/Application Support/.burrito/next_ls_erts-14.0.2_0.15.0/erts-14.0.2/bin/epmd -daemon

@slashmili
Copy link

Update: I've upgraded to Next LS v0.19.1 and use the same nvim-lspconfig as before and still get this :

Unexpected compiler response: {:error, %CompileError{file: "/Users/milad/dev/my_app/deps/ecto/mix.exs", line: 0, description: "cannot compile module Ecto.MixProject (errors have been logged)"}}'

@mhanberg
Copy link
Collaborator

mhanberg commented Mar 4, 2024

@slashmili I don't recommend swapping nextls into the elixirls lsp config config.

Can you try with the official elixir-tools.nvim plugin?

@mhanberg
Copy link
Collaborator

mhanberg commented Mar 4, 2024

With regard to the original issue, I recommend trying again with the latest, as there is functionality to handle the dependency issues

@slashmili
Copy link

You are correct! sorry for my mistake. I didn't pay attention. As of using elixir-tools.nvim, it's an option but I'd rather to keep my dependencies bear minimum. I'll try to extract the next-ls config from elixir-tools.nvim.

From my POV you may close the issue!

@mhanberg
Copy link
Collaborator

I believe #401 should close out this issue, I will likely release it in v0.20.2, please update and let me know if you can still reproduce.

I'll close the issue if I don't hear back in a while, but feel free to comment and I'll re-open

@mhanberg mhanberg closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants