Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/mix/lib/mix/dep/loader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,23 @@ defmodule Mix.Dep.Loader do
current environment, behavior can be overridden via options.
"""
def children(locked?) do
mix_children(Mix.Project.config(), locked?, []) ++ Mix.Dep.Umbrella.unloaded()
deps = mix_children(Mix.Project.config(), locked?, []) ++ Mix.Dep.Umbrella.unloaded()
# warn if project app matches a dep
warn_on_duplicate_app_name(Mix.Project.config()[:app], deps)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it inside the with_scm_and_app, so we don't have to traverse deps twice!

Copy link
Contributor Author

@pckrishnadas88 pckrishnadas88 Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback!

I’ve moved the duplicate app name warning into with_scm_and_app. Please let me know if anything else is needed.


deps
end

def warn_on_duplicate_app_name(nil, _deps), do: :ok

def warn_on_duplicate_app_name(app, deps) do
dep_apps = Enum.map(deps, & &1.app)

if app in dep_apps do
Mix.shell().error(
"warning: the application name #{inspect(app)} is the same as one of its dependencies"
)
end
end

@doc """
Expand Down
18 changes: 18 additions & 0 deletions lib/mix/test/mix/project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ defmodule Mix.ProjectTest do
end)
end

test "warns when project app name matches a dependency" do
Mix.shell(Mix.Shell.Process)

app = :clash_app

deps = [
%Mix.Dep{app: :clash_app},
%Mix.Dep{app: :other_dep}
]

Mix.Dep.Loader.warn_on_duplicate_app_name(app, deps)

assert_received {:mix_shell, :error,
[
"warning: the application name :clash_app is the same as one of its dependencies"
]}
end

test "in_project prints nice error message if fails to load file", context do
in_tmp(context.test, fn ->
File.write("mix.exs", """
Expand Down
Loading