Skip to content

Commit

Permalink
remove unloaded apps from code path
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Sep 27, 2023
1 parent 882c73a commit dbb0f67
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions apps/language_server/lib/language_server/build.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ defmodule ElixirLS.LanguageServer.Build do
end

defp purge_app(app) do
# TODO use hack with ets
modules =
case :application.get_key(app, :modules) do
{:ok, modules} -> modules
Expand All @@ -314,12 +313,27 @@ defmodule ElixirLS.LanguageServer.Build do
case Application.stop(app) do
:ok -> :ok
{:error, :not_started} -> :ok
{:error, error} -> Logger.error("Application.stop failed for #{app}: #{inspect(error)}")
{:error, error} -> Logger.warning("Application.stop failed for #{app}: #{inspect(error)}")
end

lib_dir = :code.lib_dir(app)

case Application.unload(app) do
:ok -> :ok
{:error, error} -> Logger.error("Application.unload failed for #{app}: #{inspect(error)}")
{:error, error} -> Logger.warning("Application.unload failed for #{app}: #{inspect(error)}")
end

if is_list(lib_dir) do
case :code.del_path(:filename.join(lib_dir, ~c"ebin")) do
true ->
:ok

false ->
:ok

{:error, reason} ->
Logger.warning("Unable to clean code path for #{app}: #{inspect(reason)}")
end
end
end

Expand Down

0 comments on commit dbb0f67

Please sign in to comment.