Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copier update: Updating a project creates nested folder inside the project instead of overwriting existing files #1120

Closed
keyvanm opened this issue Apr 22, 2023 · 3 comments
Labels

Comments

@keyvanm
Copy link

keyvanm commented Apr 22, 2023

Describe the problem
It seems like (please correct me if I'm wrong) that the default directory structure that copier expects when generating or reading a subproject is as follows:

repo/
  .git
  .copier-answers.yml
  project/
     src/

I have been having problems with update with a directory structure like this

repo/
  .git
  .copier-answers.yml
  src/  # please note the src is at the root of the repo right next to .coper-answers.yml

When I run update, copier does the following:

repo/
  repo/  # note the project is recreated inside the current project instead of overwriting
    .copier-answers.yml
   src/
  .git
  .copier-answers.yml
  src/

Note that instead of updating the project, it creates the project again as a nested folder inside the current project.

Template

A template structure like so:

template/
  {{ repo_name }}/
    src/
    .copier-answers.yml
copier.yml
# copier.yml
_subdirectory: template
...

To Reproduce

  1. Run copier template . with the mentioned template structure
  2. cd inside the project and run copier update
  3. Notice the incorrect update and the creation of the nested project

Logs


Expected behavior

Copier should update the existing project instead of creating a nested folder.

Screenshots/screencasts/logs

Environment

  • OS: Mac OS 12.3.1
  • Copier version: 7.0.1
  • Python version: 3.11
  • Installation method: pipx

Additional context

@keyvanm keyvanm added the bug label Apr 22, 2023
@keyvanm
Copy link
Author

keyvanm commented Apr 23, 2023

Fixed it by reducing the nesting inside our template

# Note no {{ repo_name }} directory
template/
  src/
  .copier-answers.yml
copier.yml

We now call copier like so: copier template repo_name

@keyvanm keyvanm closed this as completed Apr 23, 2023
@debo
Copy link

debo commented Dec 20, 2023

I ended up doing the same however, admittedly, it would be lovely if copier could support the original use case. It will make for an ever more streamlined and friendly experience in my humble opinion. @yajo pretty please? Alternatively could you please explain why such use case is not supported?

@pawamoy
Copy link
Contributor

pawamoy commented Dec 20, 2023

@debo the original issue is not clear to me. It shows commands that do not exist (copier template). I'd suggest you open a new discussion with your detailed use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants