Skip to content

Conversation

@pckrishnadas88
Copy link

@pckrishnadas88 pckrishnadas88 commented Dec 15, 2025

Summary

This PR adds a warning in Mix.Project when a project’s application name is the same as one of its dependencies.

Details

Currently, if a project declares an app name that is identical to one of its dependencies, Elixir doesn’t warn the user. This can lead to unexpected behaviors, such as hanging compilers when trying to start tasks from the dependency.

This fix implements warn_on_duplicate_app_name/1 in mix/project.ex that prints a warning using Mix.shell().error/1. The associated test Mix.ProjectTest verifies the behavior.

Example

If a user creates a project with:

mix new aoc

and adds {:aoc, "~> 0.16.0"} to deps, running:

mix deps.get
mix aoc.set

will print:

warning: the application name :aoc is the same as one of its dependencies

Related Issue

Fixes: [elixir-lang/elixir#14972](#14972)

@josevalim
Copy link
Member

Hi @pckrishnadas88, thank you for the PR! Although I would likely move the check elsewhere, perhaps on Mix.Dep.Loader or somewhere else where we already traverse the dependencies...

This ensures Mix emits a warning if a project's app name conflicts with one of its dependencies.
@pckrishnadas88
Copy link
Author

Hi @josevalim,

Thanks for the feedback! I’ve moved the check to Mix.Dep.Loader and added a test that verifies the warning prints when the project app name matches a dependency. Verified locally with a temporary project.

I’m still learning Elixir, so any guidance or feedback is greatly appreciated.

PTAL!

—Krishnadas

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
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.


{scm, opts} =
if is_nil(scm) and Mix.Hex.ensure_installed?(locked?) do
if is_nil(scm) and locked? and Mix.Hex.ensure_installed?(locked?) do
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants