Skip to content

Commit 737bf1b

Browse files
author
José Valim
committed
Emit proper error if parsetools is not available
1 parent 12e052e commit 737bf1b

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

lib/mix/lib/mix/compilers/erlang.ex

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ defmodule Mix.Compilers.Erlang do
9696
end
9797
end
9898

99+
@doc """
100+
Ensures the native Erlang application is available.
101+
"""
102+
def ensure_application!(app, input) do
103+
case Application.ensure_all_started(app) do
104+
{:ok, _} ->
105+
:ok
106+
{:error, _} ->
107+
Mix.raise "Could not compile #{inspect Path.relative_to_cwd(input)} because " <>
108+
"the application \"#{app}\" could not be found. This may happen if " <>
109+
"your package manager broke Erlang into multiple packages and may " <>
110+
"be fixed by installing the missing \"#{app}\" package for Erlang."
111+
end
112+
end
113+
99114
@doc """
100115
Removes compiled files.
101116
"""

lib/mix/lib/mix/tasks/compile.leex.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ defmodule Mix.Tasks.Compile.Leex do
4343

4444
Erlang.compile(manifest(), mappings, :xrl, :erl, opts[:force], fn
4545
input, output ->
46+
Erlang.ensure_application!(:parsetools, input)
4647
options = options ++ [scannerfile: Erlang.to_erl_file(output), report: true]
4748
:leex.file(Erlang.to_erl_file(input), options)
4849
end)

lib/mix/lib/mix/tasks/compile.yecc.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ defmodule Mix.Tasks.Compile.Yecc do
4343

4444
Erlang.compile(manifest(), mappings, :yrl, :erl, opts[:force], fn
4545
input, output ->
46+
Erlang.ensure_application!(:parsetools, input)
4647
options = options ++ [parserfile: Erlang.to_erl_file(output), report: true]
4748
:yecc.file(Erlang.to_erl_file(input), options)
4849
end)

0 commit comments

Comments
 (0)