clang-format command not found

In this troubleshooting guide we learn how to fix clang-format command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

clang-format: command not found

or when using sudo you get the following error message

sudo: clang-format: command not found

Solutions to clang-format: command not found

How To Fix clang-format: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu clang-format is provided by clang-format package.

clang-format is:

Clang-format is both a library and a stand-alone tool with the goal of automatically reformatting C++ sources files according to configurable style guides. To do so, clang-format uses Clang’s Lexer to transform an input file into a token stream and then changes all the whitespace around those tokens. The goal is for clang-format to both serve both as a user tool (ideally with powerful IDE integrations) and part of other refactoring tools, e.g. to do a reformatting of all the lines changed during a renaming.

This is a dependency package providing the clang format tool.

To fix this problem, we can install more using the command below.

sudo apt-get -y install clang-format

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install clang-format.

sudo apt -y install clang-format

Or if you have aptitude installed you can use the following command.

sudo aptitude install clang-format

Summary

In this tutorial we learn how to fix clang-format command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.