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 fails when runnig "invoke after-upgrade" when docker is not installed #466

Open
ap-wtioit opened this issue Apr 15, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ap-wtioit
Copy link
Contributor

Describe the bug

https://github.com/Tecnativa/doodba-copier-template/blob/e2f4efdab336d5cd32c327a007983011e1e4edbb/tasks_downstream.py#L52C1-L56C2

Adds a requirement to have docker installed otherwise no task can be run even if the task could be run without docker beeing available.

docker_compose_v2 = (
    subprocess.run([shutil.which("docker"), "compose"], capture_output=True).returncode
    == 0
)

should probably be

docker = shutil.which("docker")
docker_compose_v2 = (
    docker and 
    subprocess.run([docker, "compose"], capture_output=True).returncode
    == 0
)

Relevant logs from our CI:

running copier update -f --UNSAFE
Updating to template version 6.1.5
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Traceback (most recent call last):
  File "/root/.local/bin/invoke", line 8, in <module>
    sys.exit(program.run())
  File "/root/.local/share/pipx/venvs/invoke/lib/python3.9/site-packages/invoke/program.py", line 387, in run
    self.parse_collection()
  File "/root/.local/share/pipx/venvs/invoke/lib/python3.9/site-packages/invoke/program.py", line 479, in parse_collection
    self.load_collection()
  File "/root/.local/share/pipx/venvs/invoke/lib/python3.9/site-packages/invoke/program.py", line 716, in load_collection
    module, parent = loader.load(coll_name)
  File "/root/.local/share/pipx/venvs/invoke/lib/python3.9/site-packages/invoke/loader.py", line 91, in load
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/scaffolding/tasks.py", line 54, in <module>
    subprocess.run([shutil.which("docker"), "compose"], capture_output=True).returncode
  File "/usr/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1698, in _execute_child
    and os.path.dirname(executable)
  File "/usr/lib/python3.9/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):
  File "/root/.local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/cli/application.py", line 638, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/cli/application.py", line 633, in run
    retcode = inst.main(*tailargs)
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 424, in main
    return _handle_exceptions(inner)
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 70, in _handle_exceptions
    method()
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 422, in inner
    worker.run_update()
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 217, in __exit__
    raise value
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 422, in inner
    worker.run_update()
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 841, in run_update
    self._apply_update()
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 906, in _apply_update
    self.answers = current_worker.answers
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 217, in __exit__
    raise value
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 905, in _apply_update
    current_worker.run_copy()
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 774, in run_copy
    self._execute_tasks(self.template.tasks)
  File "/root/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 296, in _execute_tasks
    subprocess.run(task_cmd, shell=use_shell, check=True, env=local.env)
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'invoke after-update' returned non-zero exit status 1.

To Reproduce

Affected versions: 6.1.5 (probably introduced with 3d61465)

Steps to reproduce the behavior:

  1. Copy (with copier) the project in an old version
  2. Run copier update -f --UNSAFE in an environment where docker is not available

Expected behavior A clear and concise description of what you expected to happen.

Tasks not needing docker-compose nor docker compose should work without having docker installed

Additional context Add any other context about the problem here. (e.g. OS, Docker
version, ...)

We are running the update on our CI in a docker image where only docker-compose is available and not docker.

@ap-wtioit ap-wtioit added the bug Something isn't working label Apr 15, 2024
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