elixir-lsp / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
https://elixir-lsp.github.io/elixir-ls/
Apache License 2.0
1.47k stars 194 forks source link

`mix elixir_ls.release` error `function Mix.Dep.load_on_environment/1 is undefined or private` #1044

Closed sax closed 9 months ago

sax commented 9 months ago

Precheck

Environment

Current behavior

My current work team is installing ElixirLS via Nix. As a part of the recipe, the mix task mix elixir_ls.release is executed. This appears to run mix archive.build.deps, which looks like it's the forked version of the mix_task_archive_deps package. This attempts to run Mix.Dep.load_on_environment/1, which seems to have disappeared in Elixir 1.16.

Logs:

error: builder for '/nix/store/y9c80g7l8l34cn9flyzg3zz8aqg74as3-elixir-ls-0.18.0.drv' failed with exit code 1;
       last 10 log lines:
       >
       > ** (UndefinedFunctionError) function Mix.Dep.load_on_environment/1 is undefined or private
       >     (mix 1.16.0) Mix.Dep.load_on_environment([env: :prod])
       >     (mix_task_archive_deps 0.5.0) lib/mix/tasks/archive/build.deps.ex:61: Mix.Tasks.Archive.Build.Deps.list/1
       >     (mix_task_archive_deps 0.5.0) lib/mix/tasks/archive/build.deps.ex:42: Mix.Tasks.Archive.Build.Deps.build_archives/1
       >     (mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
       >     (elixir_ls_utils 0.17.10) lib/mix.tasks.elixir_ls.release.ex:17: Mix.Tasks.ElixirLs.Release.run/1
       >     (mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
       >     (elixir 1.16.0) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
       >     (mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
       For full logs, run 'nix-store -l /nix/store/y9c80g7l8l34cn9flyzg3zz8aqg74as3-elixir-ls-0.18.0.drv'.

Repo steps:

Expected behavior

I would expect to be able to create an archive release of elixir-ls on the same version of Elixir that we are trying to upgrade to.

Extra notes

I considered filing an issue with the forked repo of mix_task_archive_deps, but since it's a fork with issues disabled I'm unable to file an issue there. It seems as if that project has not been kept up to date with upstream changes, so am unclear on a preferred solution to this would be. I'd be happy to contribute to solving this with some guidance.

Thanks!

sax commented 9 months ago

Oh, just before anyone notices... the stack trace shown above is from 0.17.10, but the same stack trace is shown when compiling 0.18.0.

lukaszsamson commented 9 months ago

.ez archives release is deprecated since v0.15, please migrate to Mix.install based release https://github.com/elixir-lsp/elixir-ls#mixinstall-based-release. If you need to keep using the .ez archives release consider submitting a PR to https://github.com/rabbitmq/mix_task_archive_deps (it looks like all of the fixes on https://github.com/elixir-lsp/mix_task_archive_deps has been merged to the upstream version)

sax commented 9 months ago

Great, thanks for the feedback!