Skip to content

Commit 0f00cb0

Browse files
Warn when project app name matches a dependency (#15013)
1 parent e622a26 commit 0f00cb0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/mix/lib/mix/dep/loader.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ defmodule Mix.Dep.Loader do
202202
)
203203
end
204204

205+
project_app = Mix.Project.config()[:app]
206+
207+
if project_app && project_app == app do
208+
Mix.shell().error(
209+
"warning: the application name #{inspect(app)} is the same as one of its dependencies"
210+
)
211+
end
212+
205213
%Mix.Dep{
206214
scm: scm,
207215
app: app,

lib/mix/test/mix/tasks/deps_test.exs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,31 @@ defmodule Mix.Tasks.DepsTest do
922922
end)
923923
end
924924

925+
defmodule AppNameClashesWithDep do
926+
def project do
927+
[
928+
app: :ok,
929+
version: "0.1.0",
930+
deps: [
931+
{:ok, "0.1.0", path: "deps/ok"}
932+
]
933+
]
934+
end
935+
end
936+
937+
test "warns when project app name matches a dependency" do
938+
in_fixture("deps_status", fn ->
939+
Mix.Project.push(AppNameClashesWithDep)
940+
941+
Mix.Tasks.Deps.Get.run([])
942+
943+
msg =
944+
"warning: the application name :ok is the same as one of its dependencies"
945+
946+
assert_received {:mix_shell, :error, [^msg]}
947+
end)
948+
end
949+
925950
## deps.clean
926951

927952
defmodule CleanDepsApp do

0 commit comments

Comments
 (0)