Skip to content

Commit 99cad59

Browse files
wrachwaljosevalim
authored andcommitted
Fix read of app file located in archive .ez file (#10062)
1 parent ef4c926 commit 99cad59

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/mix/lib/mix/tasks/app.start.ex

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ defmodule Mix.Tasks.App.Start do
162162
{:error, {:file.format_error(:enoent), name}}
163163

164164
path ->
165-
case :file.consult(path) do
166-
{:ok, [{:application, _, properties} = application_data]} ->
165+
case consult_app_file_maybe_in_archive(path) do
166+
{:ok, {:application, _, properties} = application_data} ->
167167
with :ok <- :application.load(application_data) do
168168
if compile_env = validate_compile_env? && properties[:compile_env] do
169169
# Unfortunately we can only check the current app here,
@@ -182,6 +182,19 @@ defmodule Mix.Tasks.App.Start do
182182
end
183183
end
184184

185+
defp consult_app_file_maybe_in_archive(path) do
186+
# The path could be located in .ez archive
187+
case :erl_prim_loader.get_file(path) do
188+
{:ok, bin, _full_name} ->
189+
with {:ok, tokens, _} <- :erl_scan.string(String.to_charlist(bin)) do
190+
:erl_parse.parse_term(tokens)
191+
end
192+
193+
:error ->
194+
{:error, :enoent}
195+
end
196+
end
197+
185198
@doc false
186199
def type(config, opts) do
187200
cond do

0 commit comments

Comments
 (0)