Skip to content

[bug] Compiler detection broken with spaces in path #18622

@mrjoel

Description

@mrjoel

Describe the bug

My particular environment is in trying to auto detect a profile with Clang on Windows, where the install is in the default location of C:\Program Files\LLVM\bin\clang.exe. I set CC and CXX appropriately, which is reported in the log output message detect_api: CC and CXX: C:\Program Files\LLVM\bin\clang.exe, C:\Program Files\LLVM\bin\clang++.exe, however I get a warning message that no compiler is detected.

Workaround: For older versions of Conan it's possible to include double-quotes in the value of the environment variable, but that shouldn't be needed.

Should work:

$env:CC='C:\Program Files\LLVM\bin\clang.exe'

Currently required workaround:

$env:CC='"C:\Program Files\LLVM\bin\clang.exe"'

It looks like since detect_runner() in runners.py uses shell=True for the Popen call the command should include quotes where needed.

In a quick test for me locally, the following change to detect_clang_compiler() in detect_api.py causes it to work successfully for my Clang on Windows situation. It looks like most/all other calls in detect_api.py should similarly quote %s for robustness.

  def detect_clang_compiler(compiler_exe="clang"):
      try:
-         ret, out = detect_runner('%s --version' % compiler_exe)
+         ret, out = detect_runner('"%s" --version' % compiler_exe)
          if ret != 0:
              return None, None, None

How to reproduce it

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions