Skip to content

Detection of clang-format version fails in SSH remote session when clang-format is a symlink #12298

@saierd

Description

@saierd

Environment

  • OS and Version: Ubuntu 22.04
  • VS Code Version: 1.88.0
  • C/C++ Extension Version: 1.20.5
  • If using SSH remote, specify OS of remote machine: Ubuntu 20.04

Bug Summary and Steps to Reproduce

Bug Summary:

This is a follow-up to #10102 (comment)

As described in the comment history there, detection of the clang-format version sometimes seems to fail and as a result an old version of clang-format gets passed --Wno-error=unknown, which it does not support.

I could find the following conditions for this to happen:

  • The specified C_Cpp.clang_format_path points to a symlink. Replacing this path with the real path to the clang-format binary fixes the problem.
  • VS Code is connected remotely via SSH. The same settings work when using VS Code directly on the same machine.

Configuration and Logs

C_Cpp.clang_format_path is set to clang-format-8. It resolves to /usr/bin/clang-format-8, which is a symlink to ../lib/llvm-8/bin/clang-format.

C/C++ Log on Debug Level:

Formatting document: file://<file>
Formatting Engine: clangFormat
Formatting failed:
clang-format-8 -style=file -fallback-style=LLVM --Wno-error=unknown -assume-filename=<file> <file>

I could not find any logging for where the version detection happens.

clang-format-8 --version prints

clang-format version 8.0.1-9 (tags/RELEASE_801/final)

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions