Skip to content

Commit f9361b3

Browse files
committed
catch crash in Mix.Project.deps_paths
1 parent 20983fe commit f9361b3

File tree

1 file changed

+14
-1
lines changed
  • apps/language_server/lib/language_server

1 file changed

+14
-1
lines changed

apps/language_server/lib/language_server/build.ex

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,20 @@ defmodule ElixirLS.LanguageServer.Build do
141141
if module = Mix.Project.get() do
142142
build_path = Mix.Project.config()[:build_path]
143143

144-
for {app, path} <- Mix.Project.deps_paths() do
144+
deps_paths =
145+
try do
146+
# this call can raise (RuntimeError) cannot retrieve dependencies information because dependencies
147+
# were not loaded. Please invoke one of "deps.loadpaths", "loadpaths", or "compile" Mix task
148+
Mix.Project.deps_paths()
149+
catch
150+
kind, payload ->
151+
{payload, stacktrace} = Exception.blame(kind, payload, __STACKTRACE__)
152+
message = Exception.format(kind, payload, stacktrace)
153+
Logger.warning("Unable to prune mix project: #{message}")
154+
[]
155+
end
156+
157+
for {app, path} <- deps_paths do
145158
child_module =
146159
try do
147160
Mix.Project.in_project(app, path, [build_path: build_path], fn mix_project ->

0 commit comments

Comments
 (0)