From 7ee75a6a332970d952b33e382046ab506c5756fe Mon Sep 17 00:00:00 2001 From: Sawyer X Date: Mon, 16 Mar 2026 15:42:21 +0100 Subject: [PATCH] Restore pre-Path::Tiny HasLocation upward traversal semantics: A regression in app root detection was introduced by the `Path::Tiny` migration in `Dancer2::Core::Role::HasLocation`. When walking up parent directories to find an app root (`lib`+`bin` or `.dancer`), switching to `$subdir->parent` changed behavior for relative paths (notably `.`), which could stop effective upward traversal and lead to incorrect root selection on some systems. Fix by restoring pre-migration traversal behavior: * advance with `Path::Tiny::path($subdir, '..')` each iteration * stop at filesystem root via absolute-path comparison This keeps existing caller semantics intact while fixing template/public/config resolution failures caused by misdetected app location. --- lib/Dancer2/Core/Role/HasLocation.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Dancer2/Core/Role/HasLocation.pm b/lib/Dancer2/Core/Role/HasLocation.pm index bf02d70a7..4d72c6b30 100644 --- a/lib/Dancer2/Core/Role/HasLocation.pm +++ b/lib/Dancer2/Core/Role/HasLocation.pm @@ -76,9 +76,11 @@ sub _build_location { last; } - $subdir = $subdir->parent; + # Preserve pre-Path::Tiny traversal behavior: keep walking "up" + # even when current subdir is ".". + $subdir = Path::Tiny::path( $subdir, '..' ); - last if $subdir->realpath->stringify eq Path::Tiny->rootdir->stringify; + last if $subdir->absolute->stringify eq Path::Tiny->rootdir->stringify; } my $path = $subdir_found ? $subdir : $location;