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

Always quote raw args in docker runner #17002

Draft
wants to merge 4 commits into
base: develop2
Choose a base branch
from

Conversation

AbrilRBS
Copy link
Member

Changelog: Bugfix: Always quote args in Docker runner
Docs: Omit

This is a small oversight that prevented running commands like
conan create . -o="&:with_foo=True", which in bash would get confussed to try to run with_foo=True

@AbrilRBS AbrilRBS added this to the 2.8.0 milestone Sep 16, 2024
@@ -112,7 +112,7 @@ def __init__(self, conan_api, command, host_profile, build_profile, args, raw_ar

# Update conan command and some paths to run inside the container
raw_args[raw_args.index(args.path)] = self.abs_docker_path
self.command = ' '.join([f'conan {command}'] + [f'"{raw_arg}"' if ' ' in raw_arg else raw_arg for raw_arg in raw_args] + ['-f json > create.json'])
self.command = ' '.join([f'conan {command}'] + [f'"{raw_arg}"' for raw_arg in raw_args] + ['-f json > create.json'])
Copy link
Member

Choose a reason for hiding this comment

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

I know it might be difficult, but it would be great to have some test that covers this, to guarantee it doesn't break in the future.

@AbrilRBS AbrilRBS modified the milestones: 2.8.0, 2.9.0 Sep 27, 2024
@czoido czoido modified the milestones: 2.9.0, 2.10.0 Oct 28, 2024
@AbrilRBS
Copy link
Member Author

AbrilRBS commented Dec 2, 2024

Before the fix:

E           Conan version 2.10.0-dev
E           
E           
E           ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
E           | Running in container: "conan create "/root/conanrunner/path with spaces" -pr:h host -pr:b build -o=&:shared=True -f json > create.json" |
E           └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
E           
E           /bin/bash: line 1: :shared=True: command not found
E           
E           ┌───────────────────────────┐
E           | ERROR: Stopping container |
E           └───────────────────────────┘
E           
E           
E           ┌───────────────────────────┐
E           | ERROR: Removing container |
E           └───────────────────────────┘
E           
E           ERROR: "conan create "/root/conanrunner/path with spaces" -pr:h host -pr:b build -o=&:shared=True -f json > create.json" inside docker fail
E           
E           Last command output: /bin/bash: line 1: :shared=True: command not found
E           
E           
E           ================================== Traceback: ==================================
E           Traceback (most recent call last):
E             File "/Users/ruben/coding/conan/conan/internal/runner/docker.py", line 155, in run
E               self.run_command(self.command)
E             File "/Users/ruben/coding/conan/conan/internal/runner/docker.py", line 221, in run_command
E               raise RunnerException(command=command, stdout_log=stdout_log, stderr_log=stderr_log)
E           conan.internal.runner.RunnerException
E           
E           During handling of the above exception, another exception occurred:
E           
E           Traceback (most recent call last):
E             File "/Users/ruben/coding/conan/conan/test/utils/tools.py", line 569, in _run_cli
E               command.run(args)
E             File "/Users/ruben/coding/conan/conan/cli/cli.py", line 192, in run
E               command.run(self._conan_api, args[0][1:])
E             File "/Users/ruben/coding/conan/conan/cli/command.py", line 180, in run
E               info = self._method(conan_api, parser, *args)
E                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E             File "/Users/ruben/coding/conan/conan/cli/commands/create.py", line 83, in create
E               return runner_instance(conan_api, 'create', profile_host, profile_build, args, raw_args).run()
E                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E             File "/Users/ruben/coding/conan/conan/internal/runner/docker.py", line 162, in run
E               raise ConanException(f'"{e.command}" inside docker fail'
E           conan.errors.ConanException: "conan create "/root/conanrunner/path with spaces" -pr:h host -pr:b build -o=&:shared=True -f json > create.json" inside docker fail
E           
E           Last command output: /bin/bash: line 1: :shared=True: command not found

@czoido czoido marked this pull request as draft December 2, 2024 17:01
@czoido czoido modified the milestones: 2.10.0, 2.11.0 Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants