Skip to content
Open
Changes from all 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
3 changes: 2 additions & 1 deletion copier/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,10 @@ def resolved_vcs_ref(self) -> str | None:
@cached_property
def subproject(self) -> Subproject:
"""Get related subproject."""
default_answers_file = Path(".copier-answers.yaml") if Path(".copier-answers.yaml").exists() else Path(".copier-answers.yml")
Copy link
Member

Choose a reason for hiding this comment

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

This won't work because the Path object passed to the answers_relpath argument of Subproject(local_abspath=..., answers_relpath=...) is the path of the answers file relative to local_abspath. Path(".copier-answers.yaml").exists() checks whether .copier-answers.yaml exists in the current working directory, which is not guaranteed to be local_abspath.

result = Subproject(
local_abspath=self.dst_path.absolute(),
answers_relpath=self.answers_file or Path(".copier-answers.yml"),
answers_relpath=self.answers_file or default_answers_file,
)
self._cleanup_hooks.append(result._cleanup)
return result
Expand Down