Skip to content

Store ~p warning file relative to cwd - #6889

Merged
SteffenDE merged 2 commits into
phoenixframework:mainfrom
onnimonni:relative-verified-route-file
Nov 2, 2026
Merged

SteffenDE merged 2 commits into
phoenixframework:mainfrom
onnimonni:relative-verified-route-file

Conversation

@onnimonni

@onnimonni onnimonni commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

~p route warnings (no route path for ... matches ...) are emitted from @after_verify, using the warn_location file captured at compile time. When a copy of the project reuses _build (git worktree or copy-on-write clone, compiled with check_cwd: false), they point at the original checkout's absolute paths, so editors and coding agents edit the wrong files.

Fix: store Path.relative_to_cwd(file) in warn_location. Elixir resolves relative diagnostic paths against the current directory when it prints them.

Tests: full suite passes (1113).

This is one of the remaining relocation issues from #6855. Others: phoenixframework/phoenix_template#17 (__mix_recompile__? root) and phoenixframework/phoenix_live_view#4489 (component call file).

~p warnings are emitted from @after_verify using the file stored at compile
time. With an absolute path, a copy of the project reusing the build (git
worktree, copy-on-write clone, compiled with check_cwd: false) reported
warnings in the original checkout's files.
SteffenDE added a commit to SteffenDE/elixir that referenced this pull request Nov 2, 2026
Warnings emitted from @after_verify callbacks run in the parallel
checker, where :elixir_compiler_file is not set. Their source field is
therefore whatever :file the callback passed to IO.warn/2. The checker
already made :file absolute when collecting the diagnostic but left
:source untouched.

Mix attaches warnings to their source files by matching :source against
absolute paths. A relative :source matched nothing, so such a warning
was printed once and never persisted in the manifest: later compilations
did not print it again with --all-warnings, and a no-op compilation
passed --warnings-as-errors despite it.

Phoenix wants to store these paths relative to the project so that a
build reused from another directory, such as a git worktree, reports
the right files (phoenixframework/phoenix#6889).
Mix persists compiler warnings by their absolute source path. Elixir
makes the file of a warning emitted from @after_verify absolute again
when collecting it, but not its source. A warning with a relative file
was therefore printed once and never stored in the manifest: later
compilations did not print it again with --all-warnings, and a no-op
compilation passed --warnings-as-errors.

Keep storing the file relative to the project, so that copies of the
project reusing the build report their own files, and expand it against
the current directory when the warning is emitted.
@SteffenDE
SteffenDE merged commit 6daf29b into phoenixframework:main Nov 2, 2026
16 checks passed
@SteffenDE

Copy link
Copy Markdown
Member

Thank you! 🙌🏻

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants