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

** (Mix.Error) Can't continue due to errors on dependencies #71

Closed
andrelip opened this issue Mar 28, 2018 · 17 comments
Closed

** (Mix.Error) Can't continue due to errors on dependencies #71

andrelip opened this issue Mar 28, 2018 · 17 comments

Comments

@andrelip
Copy link

ElixirLS is giving me an exception on VS Code Problems window that is not happing anywhere else (not with mix compile or releasing using distillery). The system also runs fine.

** (Mix.Error) Can't continue due to errors on dependencies

Any tips on how to handle that problem? Is there a different elixir compile option so I can execute to try to reproduce that crash on terminal?

Environment

  • Elixir & Erlang versions (elixir --version): 1.6
  • Operating system: OSX 10.13.2
  • Client (editor or IDE): Code 1.21.1

Crash report template

an exception was raised:
** (Mix.Error) Can't continue due to errors on dependencies
(mix) lib/mix.ex:291: Mix.raise/1
(mix) lib/mix/tasks/deps.loadpaths.ex:27: Mix.Tasks.Deps.Loadpaths.run/1
(mix) lib/mix/task.ex:314: Mix.Task.run_task/3
(mix) lib/mix/tasks/loadpaths.ex:34: Mix.Tasks.Loadpaths.run/1
(mix) lib/mix/task.ex:314: Mix.Task.run_task/3
(mix) lib/mix/tasks/compile.ex:87: Mix.Tasks.Compile.run/1
(mix) lib/mix/task.ex:314: Mix.Task.run_task/3
(language_server) lib/language_server/build.ex:162: ElixirLS.LanguageServer.Build.compile/0

@norpan
Copy link

norpan commented Apr 16, 2018

I had the exact same error. It went away when I removed the deps directory and let it fetch dependencies again.

@JakeBecker
Copy link
Owner

I'm guessing that running the task to deps.get before compiling is somehow screwing with the dependencies cache. I'm gonna have to play around with it a bit. Let me know if you figure out a reliable way to reproduce it.

@JakeBecker
Copy link
Owner

Until I fix this, try setting elixirLS.fetchDeps to false in your settings. If the problem was caused by the automatic fetching of dependencies, this might fix it.

@lukaszsamson
Copy link
Contributor

Setting elixirLS.fetchDeps to false does not fix the issue. I run into it every time I upgrade erlang or elixir version.
Only rm -r deps _build .elixir_ls && mix deps.get helps.

@suprnova32
Copy link

It also happens when adding a new dependency to mix.exs, or when updating them. It used to be fixable by simply quitting VSCode and opening again, but lately I need to remove .elixir_ls/deps in order to get the error to go away.

@bobics
Copy link

bobics commented Jul 23, 2018

I actually have to quit VSCode before nuking the folders (per @lukaszsamson's comment), otherwise my deps only partially get fetched. It would leave my deps folder in borked state (hence the errors). Perhaps ElixirLS is locking a folder or there's a race condition. I think the magic sauce is:

  1. Set elixirLS.fetchDeps to false.
  2. Close VSCode just to be safe.
  3. rm -r deps _build .elixir_ls && mix deps.get.
  4. Start VSCode.

You should only have to do this once.

@AsharDweedar
Copy link

This would solve the problem but it sometime occur again with switching between branches.

@michallepicki
Copy link

michallepicki commented Aug 2, 2018

The error materialized itself for me in a situation where I already had elixirLs.fetchDeps set to false, and I switched from working on a branch with an added dependency to a branch without it.

These elixir-ls log lines before this error may be helpful too:

[Warn  - 2:27:21 PM] Unchecked dependencies for environment test:

[Warn  - 2:27:21 PM] * unused_dependency_name (Hex package)

[Warn  - 2:27:21 PM]   the dependency is not locked. To generate the "mix.lock" file run "mix deps.get"

The project does compile and run from the command line with this additional unnecessary dependency in that situation, so only elixir-ls has a problem with this.

rm -r deps _build .elixir_ls/build .elixir_ls/dialyzer_tmp did not suffice and I had to close VSCode to get rid of this error.

Possibly related problem: when switching to a branch with a new dependency added, after doing mix deps.get && mix deps.compile && mix compile && iex -S mix phx.server I get the project up and running from the terminal, but elixir-ls doesn't compile this new dependency and throws an error that module SomeModule is not loaded and could not be found. I also have to close VSCode to mitigate that.

@macbem
Copy link

macbem commented Sep 13, 2018

This issue is in general related to the fact that mix.exs doesn't seem to be re-evaluated when an error happens in the file, even after changes.

For example, I added a dependency as a list instead of a tuple, saved the file and got a Dependency specified in the wrong format error. I fixed the dependency, but the error is still there. It will fix itself once I trigger a VS Code window reload.

Maybe we should have a command to re-evaluate a file or restart the language service? For example, TypeScript LS allows us to restart it via a VS Code command and it fixes most issues with persisting errors.

@webdeb
Copy link

webdeb commented Oct 26, 2018

@JakeBecker I could reproduce it immediately by creating a new umbrella project

  1. mix new exls --umbrella
  2. Open the mix.exs and after elixir-ls initialisation it showed me the first error:
[ElixirLS]
an exception was raised:
    ** (Enum.EmptyError) empty error
        (elixir) lib/enum.ex:1843: Enum.reduce/2
        (mix) lib/mix/tasks/compile.ex:93: Mix.Tasks.Compile.run/1
        (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
        (language_server) lib/language_server/build.ex:162: ElixirLS.LanguageServer.Build.compile/0
        (language_server) lib/language_server/build.ex:22: anonymous fn/2 in ElixirLS.LanguageServer.Build.build/3
        (stdlib) timer.erl:166: :timer.tc/1
        (language_server) lib/language_server/build.ex:13: anonymous fn/2 in ElixirLS.LanguageServer.Build.build/3
        (kernel) global.erl:430: :global.trans/4

Then I added distillery to my deps, saved the file. And the error changed to:

[ElixirLS]
an exception was raised:
    ** (Mix.Error) Can't continue due to errors on dependencies
        (mix) lib/mix.ex:291: Mix.raise/1
        (mix) lib/mix/tasks/deps.loadpaths.ex:27: Mix.Tasks.Deps.Loadpaths.run/1
        (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
        (mix) lib/mix/tasks/loadpaths.ex:34: Mix.Tasks.Loadpaths.run/1
        (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
        (mix) lib/mix/tasks/compile.ex:87: Mix.Tasks.Compile.run/1
        (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
        (language_server) lib/language_server/build.ex:162: ElixirLS.LanguageServer.Build.compile/0

fetchDeps is set to false

@pietrofxq
Copy link

I just had this issue when specifying a version of a dep that was not compatible with my current version of elixir. Even after changing the version and refetching the deps and restarting vscode, the error wasn't gone. Only solution was to delete the deps folder and fetch again as mentioned above.

@jedeleh
Copy link

jedeleh commented Dec 3, 2018

I had this issue and I found that simply restarting Atom fixed it. I didn't have to sacrifice a chicken or anything else more invasive.

@jedeleh
Copy link

jedeleh commented Jan 17, 2019

I was able to make this stop happening by changing 2 configuration settings in ElixirLS:

  1. uncheck Fetch Deps automatically option
  2. changed Project Dir to . (it was empty and had a red error alert around it)
    When I restarted VScode the issue was resolved.

This does mean that you have to run mix deps.get and deps.compile manually when you make changes, but I kind of prefer that--I know the state of things in my conceptual understanding of my deps :)

@JakeBecker
Copy link
Owner

This project has moved!

It's now being maintained by proactive volunteers from the Elixir community over 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 if you're using VS Code.

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!

@jacmacmod
Copy link

m -r deps _build .elixir_ls && mix deps.get

This did not help

@Deankinyua
Copy link

I was having this issue ..............deleting the whole .elixir_ls directory and the mix.lock file worked for me.

@miguno
Copy link

miguno commented Sep 10, 2024

I had a very similar problem and found my way here via a Google search.

My solution

For others reading this, here's what I needed to do:

  1. Stop your IDE/editor including the elixir LSP.
  2. Kill any left-over elixir/elixir-ls processes. (This was important.) Find them via e.g. procs elixir or ps axu | grep elixir.
  3. In your project directory: rm -rf .elixir_ls _build mix.lock && mix deps.get.
  4. Restart your IDE/editor including the elixir LSP.

Environment

  • elixir-ls v0.23.0
  • Elixir 1.17.2 (compiled with Erlang/OTP 27)
  • Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]

Error message

The error message I originally encountered was (first few lines):

[ERROR][2024-09-10 20:08:13] ...lsp/handlers.lua:623    "Process #PID<0.287.0> raised an exception\n** (Mix.Error) Can't continue due to errors on dependencies\n    (mix 1.17.2) lib/mix.ex:588: Mix.raise/2\n    (m
ix 1.17.2) lib/mix/tasks/deps.loadpaths.ex:48: Mix.Tasks.Deps.Loadpaths.run/1\n    (mix 1.17.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5\n    (mix 1.17.2) lib/mix/tasks/loadpaths.ex:37: Mix.Tasks
.Loadpaths.run/1\n    (mix 1.17.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5\n    (mix 1.17.2) lib/mix/tasks/compile.ex:153: Mix.Tasks.Compile.run/1\n    (mix 1.17.2) lib/mix/task.ex:495: anonymou
s fn/3 in Mix.Task.run_task/5\n    (language_server 0.23.0) lib/language_server/build.ex:442: ElixirLS.LanguageServer.Build.run_mix_compile/1\n    (language_server 0.23.0) lib/language_server/build.ex:80: anonymou
s fn/3 in ElixirLS.LanguageServer.Build.build/3\n    (stdlib 6.0) timer.erl:590: :timer.tc/2\n    (language_server 0.23.0) lib/language_server/build.ex:20: anonymous fn/3 in ElixirLS.LanguageServer.Build.build/3\n
    (kernel 10.0) global.erl:699: :global.trans/4"

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