clang-format-diff-9 command not found

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

Introduction

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

clang-format-diff-9: command not found

or when using sudo you get the following error message

sudo: clang-format-diff-9: command not found

Solutions to clang-format-diff-9: command not found

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

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

clang-format-9 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 package also provides vim and emacs plugins.

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

sudo apt-get -y install clang-format-9

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

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

sudo apt -y install clang-format-9

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

sudo aptitude install clang-format-9

Summary

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