Skip to content

Commit 3550dd1

Browse files
committed
Do not crash when getting docs for missing erts appdir
Closes #10437.
1 parent 7e44b88 commit 3550dd1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/elixir/lib/code.ex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,8 +1373,17 @@ defmodule Code do
13731373
:error ->
13741374
case :code.which(module) do
13751375
:preloaded ->
1376-
path = Path.join([:code.lib_dir(:erts), "doc", "chunks", "#{module}.chunk"])
1377-
fetch_docs_from_chunk(path)
1376+
# The erts directory is not necessarily included in releases
1377+
# unless it is listed as an extra application.
1378+
case :code.lib_dir(:erts) do
1379+
path when is_list(path) ->
1380+
[path, "doc", "chunks", "#{module}.chunk"]
1381+
|> Path.join()
1382+
|> fetch_docs_from_chunk()
1383+
1384+
{:error, _} ->
1385+
{:error, :chunk_not_found}
1386+
end
13781387

13791388
_ ->
13801389
{:error, :module_not_found}

0 commit comments

Comments
 (0)