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

Update Failure - ValueError: invalid literal for int() #404

Open
bosd opened this issue Sep 14, 2023 · 1 comment
Open

Update Failure - ValueError: invalid literal for int() #404

bosd opened this issue Sep 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@bosd
Copy link

bosd commented Sep 14, 2023

Describe the bug

When performing an update. It fails.

To Reproduce

Affected versions:
Copier 8.2.0

Steps to reproduce the behavior:

On an exsisting doodba project, try to update the template.

  1. copier update --trust
  2. Result: ValueError: invalid literal for int() with base 10: 'I will use an external PostgreSQL server'
    see Traceback
/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/template.py:133: OldTemplateWarning: This template was designed for Copier 7.0.1, but your version of Copier is 8.2.0. You could find some incompatibilities.
  warn(
Updating to template version 5.2.0
/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/template.py:133: OldTemplateWarning: This template was designed for Copier 4.1.0, but your version of Copier is 8.2.0. You could find some incompatibilities.
  warn(
Traceback (most recent call last):
  File "/home/username/.local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
             ^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/plumbum/cli/application.py", line 638, in run
    inst, retcode = subapp.run(argv, exit=False)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/plumbum/cli/application.py", line 633, in run
    retcode = inst.main(*tailargs)
              ^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/cli.py", line 66, in handle_exceptions
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/cli.py", line 365, in main
    with self._worker(
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 204, in __exit__
    raise value
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/cli.py", line 372, in main
    worker.run_update()
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 814, in run_update
    self._apply_update()
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 833, in _apply_update
    with replace(
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 204, in __exit__
    raise value
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 842, in _apply_update
    old_worker.run_copy()
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 733, in run_copy
    self._ask()
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/main.py", line 433, in _ask
    answer = question.parse_answer(result.init[var_name])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/user_data.py", line 423, in parse_answer
    choices = self._formatted_choices
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/user_data.py", line 307, in _formatted_choices
    self.cast_answer(c.value)
  File "/home/username/.local/pipx/venvs/copier/lib64/python3.11/site-packages/copier/user_data.py", line 218, in cast_answer
    return type_fn(answer)
           ^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'I will use an external PostgreSQL server'

Expected behavior A clear and concise description of what you expected to happen.
Copier to update the project

Additional context
Copier 8.2.0
This template was designed for Copier 7.0.1, but your version of Copier is 8.2.0. You could find some incompatibilities.
This template was designed for Copier 4.1.0, but your version of Copier is 8.2.0. You could find some incompatibilities.

The .copier-answers.yml file actually contains:
postgres_version: 13

The mentioned command here in the readme with --force is no longer a valid argument
https://github.com/Tecnativa/doodba-copier-template/blob/19b5ecbba0b0c5d645ed44b6d3dc8e680c2c2815/README.md?plain=1#L89C1-L92C8

@bosd bosd added the bug Something isn't working label Sep 14, 2023
@Tardo
Copy link
Contributor

Tardo commented Sep 15, 2023

The main problem is that your copier.yaml is not compatible with the copier version that you are using.

The reason: When you're updating from an older template to a newer, Copier will try to produce a vanilla project with the old template before updating it, to be able to extract a smart diff and apply the required changes to your subproject.
This means that an incompatible project cannot be updated.

A possible solution would be to try to upgrade using a version of copier that works with the current project.
Another solution would be to manually fix the copier.yml file to make it compatible with newer versions of copier.

Perhaps there are better solutions. Maybe with copier 8.3.0 and use recopy :/

Additional Notes:

  • Template versions before 5.1.4 are not compatible with latest pyhton versions (pre-commit regex issue).
  • Template versions before 3.0.0 are not compatible with latest copier versions ('postgres_version' question has invalid choice type).
  • copier-answers before 5.2.0 are not compatible with latest copier versions (null answers are not supported for some question types).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants