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 Can't continue due to errors on dependencies error #120

Closed
axelson opened this issue Feb 12, 2020 · 11 comments · Fixed by #777
Closed

Mix Can't continue due to errors on dependencies error #120

axelson opened this issue Feb 12, 2020 · 11 comments · Fixed by #777
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@axelson
Copy link
Member

axelson commented Feb 12, 2020

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

A little more info at: https://github.com/elixir-lsp/elixir-ls/pull/110/files/b82d658bd86be7ed1c649601cd9bedd7e7c83764..225c5ee9ffcabb9fde0143cd7695b8b411ddad68#r377047068

This needs concrete reproduction steps.

@omar8792
Copy link

omar8792 commented Feb 24, 2020

When i start vs code i get this error too:

an exception was raised:
    ** (Mix.Error) Can't continue due to errors on dependencies
        (mix) lib/mix.ex:389: Mix.raise/1
        (mix) lib/mix/tasks/deps.loadpaths.ex:28: Mix.Tasks.Deps.Loadpaths.run/1
        (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
        (mix) lib/mix/tasks/loadpaths.ex:35: Mix.Tasks.Loadpaths.run/1
        (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
        (mix) lib/mix/tasks/compile.ex:90: Mix.Tasks.Compile.run/1
        (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
        (language_server) lib/language_server/build.ex:164: ElixirLS.LanguageServer.Build.compile/0ElixirLS

elixir:
Erlang/OTP 22 [erts-10.5.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.9.1 (compiled with Erlang/OTP 22)

erlang:
Erlang/OTP 22 [erts-10.5.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Eshell V10.5.1 (abort with ^G)

running on docker container with ububtu 19.10

here is my mix.ex

defmodule Crash.Mixfile do
  use Mix.Project

  def project do
    [
      app: :crash,
      version: get_version(),
      elixir: "~> 1.4",
      elixirc_paths: elixirc_paths(Mix.env()),
      elixirc_options: elixirc_options(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :production,
      test_coverage: [tool: ExCoveralls],
      preferred_cli_env: [coveralls: :test, e2e: :test],
      aliases: aliases(),
      deps: deps(),
      dialyzer: [plt_add_apps: [:mix, :ex_unit], plt_add_deps: :transitive, ignore_warnings: ".dialyzerignore"]
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Crash.Application, %{env: Mix.env()}},
      extra_applications: [:logger, :runtime_tools]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(env) when env in [:dev, :test], do: ["lib", "test/support", "credo"]
  defp elixirc_paths(:qa), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Elixir compiler options
  defp elixirc_options(env) when env in [:dev, :test], do: [long_compilation_threshold: 60]
  defp elixirc_options(_), do: []

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:absinthe, "~> 1.4"},
      {:absinthe_ecto, "~> 0.1"},
      {:absinthe_plug, "~> 1.4"},
      {:absinthe_relay, "~> 1.4"},
      {:amqpx, "~> 5.2-pre"},
      {:amqp_client, "~> 3.7.20-rc", override: true},
      {:bamboo, "~> 1.1"},
      {:bamboo_smtp, "~> 2.0"},
      {:basic_auth, "~> 2.2.2"},
      {:briefly, "~> 0.3"},
      {:cachex, "~> 3.0"},
      {:cowboy, "~> 2.7.0"},
      {:csv, "~> 2.1"},
      {:csv_schema, "~> 0.2.2"},
      {:distillery, "~> 2.1"},
      {:ecto_enum, "~> 1.2"},
      {:ecto_sql, "~> 3.0"},
      {:ex_aws, "~> 2.0"},
      {:ex_aws_s3, "~> 2.0"},
      {:exq, "~> 0.9"},
      {:fetcher, "~> 0.1"},
      {:fun_with_flags, "~> 1.0"},
      {:fun_with_flags_ui, "~> 0.4"},
      {:gettext, "~> 0.11"},
      {:guardian, "~> 2.0"},
      {:http_mock_pal, "~> 1.0"},
      {:httpoison, "~> 1.1"},
      {:jason, "~> 1.1"},
      {:lager, "~> 3.8", override: true},
      {:mariaex, "~> 0.8"},
      {:myxql, "~> 0.3.1"},
      {:mime, "~> 1.1"},
      {:mock, "~> 0.3"},
      {:noether, "~> 0.2.1"},
      {:parallel_task, "~> 0.1.0"},
      {:phoenix, "~> 1.4.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:phoenix_html, "~> 2.6"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_pubsub_redis, "~> 2.1"},
      {:plug_cowboy, "~> 2.0"},
      {:posexional, "~> 0.4"},
      {:postgrex, ">= 0.0.0"},
      {:prima_logger_logstash_backend, "~> 1.0"},
      {:quantum, "~> 2.3"},
      {:rabbit_common, "~> 3.7.20-rc", override: true},
      {:redix, "~> 0.8"},
      {:statix, github: "primait/statix", branch: "feature/switch_from_config"},
      {:sweet_xml, "~> 0.6"},
      {:timex, "~> 3.1"},
      {:typed_struct, "~> 0.1.4", runtime: false},
      {:elixir_uuid, "~> 1.2"}
    ] ++ deps_dev()
  end

  defp deps_dev(),
    do: [
      {:credo, "~> 1.0", only: [:dev, :test]},
      {:ex_prima_toolbox, ">= 0.0.0", only: :dev},
      {:excoveralls, "~> 0.7", only: :test},
      {:exq_ui, "~> 0.10"},
      {:dialyxir, "1.0.0-rc.7", only: [:dev, :test], runtime: false},
      {:faker, "~> 0.11", only: [:dev, :test, :qa]},
      {:hound, "~> 1.0", only: [:dev, :test]},
      {:phoenix_live_reload, "~> 1.2", only: :dev}
    ]

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.seeds": [
        "run priv/repo/prima_msa_seeds.exs",
        "run priv/repo/seeds.exs",
        "run priv/fun_with_flags.exs"
      ],
      "ecto.setup": ["ecto.create", "ecto.migrate --log-sql", "ecto.seeds"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      "ecto.init": ["ecto.drop", "ecto.create --quiet", "ecto.migrate"],
      test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
      serve: "phx.server",
      s: "phx.server",
      check: ["format.check", "credo -a", "dialyzer"],
      "fe.check": ["elm.check_format", "elm.analyze", "npm.lint"],
      "format.all": ["format mix.exs 'lib/**/*.{ex,exs}' 'test/**/*.{ex,exs}' 'config/*.{ex,exs}'"],
      "format.check": ["format --check-formatted mix.exs 'lib/**/*.{ex,exs}' 'test/**/*.{ex,exs}' 'config/*.{ex, exs}'"],
      c: "compile",
      ct: "compile --all-warnings --warnings-as-errors --ignore-module-conflict --debug-info",
      "deps.clean.unused": "deps.clean --unlock --unused"
    ]
  end

  defp get_version() do
    case System.get_env("DRONE_TAG") do
      "" -> default_version()
      nil -> default_version()
      drone_tag -> drone_tag
    end
  end

  defp default_version(), do: "0.0.0-#{DateTime.to_unix(DateTime.utc_now())}"
end

@axelson
Copy link
Member Author

axelson commented Feb 26, 2020

@omar8792 if you could reproduce this on a smaller project (or one an openly published project) that would be very helpful. Also does this error persist doing a rm -rf .elixir_ls from your project directory?

@sosodev
Copy link

sosodev commented Apr 26, 2020

FWIW updating my project's dependencies caused this issue and removing the .elixir_ls directory resolved it

@dogweather
Copy link

@sosodev 's solution works for me: I've been having this problem on and off.

@Sgoettschkes
Copy link

@omar8792 if you could reproduce this on a smaller project (or one an openly published project) that would be very helpful. Also does this error persist doing a rm -rf .elixir_ls from your project directory?

I tried to create a setup with which this reproducible happens. On macOS with Visual Code Insider and ElixirLS 0.6.2 installed and elixirLS.fetchDeps disabled:

  1. Create new project on the command line, using mix new test_ls
  2. Open the project in Visual Code Insider, open mix.ex and open the ElixirLS Output Window
  3. Add {:phoenix, "~> 1.5.0"} to the deps function to add the dependency.
  4. First result: ** (Mix.Error) Can't continue due to errors on dependencies error in ElixirLS Output
  5. Run mix deps.get on console
  6. ElixirLS compiles and errors are resolved
  7. Change version of phoenix to "~> 1.4.0"
  8. Second Result: ** (Mix.Error) Can't continue due to errors on dependencies error in ElixirLS Output
  9. Run mix deps.get on console
  10. ElixirLS compiles but fails
== Compilation error in file lib/phoenix/endpoint/cowboy_adapter.ex ==
** (CompileError) lib/phoenix/endpoint/cowboy_adapter.ex:78: cannot import Phoenix.Endpoint.Cowboy2Adapter.info/3 because it is undefined or private
    (elixir 1.11.2) src/elixir_import.erl:64: :elixir_import.calculate/6
    (elixir 1.11.2) src/elixir_import.erl:18: :elixir_import.import/4
  1. mix deps.compile on the console works fine, as expected
  2. ElixirLS still reports ** (Mix.Error) Can't continue due to errors on dependencies

I hope this helps solving this issue. It seems that adding new dependencies does not cause problems, but changing or removing does.

@lukaszsamson lukaszsamson added bug Something isn't working help wanted Extra attention is needed labels Nov 28, 2020
@thojanssens
Copy link

I have this error on my mix.exs file. Tried to remove deps and refetch dependencies, also tried to remove .elixir_ls, but the problem persists.

@numkem
Copy link

numkem commented Apr 30, 2021

I have this error on my mix.exs file. Tried to remove deps and refetch dependencies, also tried to remove .elixir_ls, but the problem persists.

I've pulled from latest master and deleted both _build and .elixir-ls folders and that seems to have worked for me.

@mtrudel
Copy link

mtrudel commented Apr 7, 2022

I've had success with running MIX_ENV=test mix deps.get. I think elixir-ls runs in a test env, so maybe that's part of the reason.

I've also had to do this at all levels of an umbrella project (ie: run MIX_ENV=test mix deps.get in the root, and any sub projects whose deps have recently changed.

@lukaszsamson
Copy link
Collaborator

Thanks @Sgoettschkes for reliable repro steps. I was finally able to pinpoint the issue. Turns out that persistent mix state was not properly cleared and it broke dependency loading. After more than 4 years I have a fix for what was originally reported in JakeBecker/elixir-ls#71

lukaszsamson added a commit that referenced this issue Nov 26, 2022
Purge all modules from changed and removed deps, remove from code paths
Fixes #120
Fixes #688
lukaszsamson added a commit that referenced this issue Nov 26, 2022
* update readme

* run formatter

* Unload changed deps

Purge all modules from changed and removed deps, remove from code paths
Fixes #120
Fixes #688

* run ci on ubuntu 20.04

22.04 is OTP  >= 24

* fix warnings
@sel-carlitos
Copy link

I had the same error in a brand-new project after running:

  • mix phx.new . --app hello_world

The error goes away after running:

  • mix deps.get
  • vscode Reload Window

@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
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.