From dabda34fdb009cc6b2bcd3c158ddb2470c1acc30 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Wed, 8 Jun 2022 16:46:38 -0500 Subject: [PATCH] Handle venv path special chars in coursier fetch (#15701) On one system (a gentoo linux box), uname reports a very verbose processor name which is then used to build the pants venv path. That verbose processor name includes "Intel(R)" and other symbols including parentheses and at: `()@` The coursier fetch script did not escape the python_path, so running `./pants lint ::` on the pants codebase results in this error: ``` __coursier/coursier_fetch_wrapper_script.sh: line 11: syntax error near unexpected token `R' ``` The full path that triggered this error is: ``` /home/cognifloyd/.cache/pants/pants_dev_deps/Linux.x86_64.Intel(R).Core(TM).i7-3610QM.CPU.@.2.30GHz.py37.venv/bin/python ``` This PR fixes that by wrapping python_path in single quotes in the coursier script. [ci skip-rust] [ci skip-build-wheels] --- src/python/pants/jvm/resolve/coursier_setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/pants/jvm/resolve/coursier_setup.py b/src/python/pants/jvm/resolve/coursier_setup.py index d6d17b12c85..da9eaa71add 100644 --- a/src/python/pants/jvm/resolve/coursier_setup.py +++ b/src/python/pants/jvm/resolve/coursier_setup.py @@ -252,8 +252,8 @@ async def setup_coursier( coursier_wrapper_script = COURSIER_FETCH_WRAPPER_SCRIPT.format( repos_args=repos_args, coursier_working_directory=Coursier.working_directory_placeholder, - python_path=python.path, - coursier_bin_dir=Coursier.bin_dir, + python_path=shlex.quote(python.path), + coursier_bin_dir=shlex.quote(Coursier.bin_dir), ) post_process_stderr = POST_PROCESS_COURSIER_STDERR_SCRIPT.format(python_path=python.path)