Install clang format - Hyeonykim/toolConfiguration GitHub Wiki

1. Install clang-format executable by npm or apt

  • In case of windows use npm

    C:\Users\username>npm install -g clang-format
    C:\Users\username\AppData\Roaming\npm\git-clang-format -> C:\Users\username\AppData\Roaming\npm\node_modules\clang-format\bin\git-clang-format
    C:\Users\username\AppData\Roaming\npm\clang-format -> C:\Users\username\AppData\Roaming\npm\node_modules\clang- 
    format\index.jsC:\Users\username\AppData\Roaming\npm\check-clang-format -> C:\Users\username\AppData\Roaming\npm\node_modules\clang-format\bin\check-clang-format.js
    
    C:\Users\username>C:\Users\username\AppData\Roaming\npm\clang-format --version
    clang-format NPM version 1.8.0 at C:\Users\username\node_modules\clang-format\index.js
    clang-format version 15.0.0 (https://github.com/llvm/llvm-project.git 596752863e27e6b4b89e34ecfcf5317a5bf46b52)
    
  • In case of ubuntu use npm or apt

    • Use npm
    $ npm install -g clang-format
    added 19 packages, and audited 20 packages in 569ms
    
    4 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    
    $ npm list -g
    /home/username/.node/lib
    └── [email protected]
    
    $ ls /home/username/.node/lib/node_modules/clang-format/bin/linux_x64/clang-format 
    /home/username/.node/lib/node_modules/clang-format/bin/linux_x64/clang-format
    
    $ /home/username/.node/lib/node_modules/clang-format/bin/linux_x64/clang-format --version
    clang-format version 15.0.0 (https://github.com/llvm/llvm-project.git 596752863e27e6b4b89e34ecfcf5317a5bf46b52)
    
    • Use apt
    $ sudo apt-get install clang-format -y
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following additional packages will be installed:
      clang-format-14 libbsd0 libclang-cpp14 libedit2 libexpat1 libicu70 libllvm14 libmd0 libmpdec3 libpython3-stdlib libpython3.10-minimal libpython3.10-stdlib libreadline8
      libsqlite3-0 libxml2 media-types python3 python3-minimal python3.10 python3.10-minimal readline-common
    Suggested packages:
      python3-doc python3-tk python3-venv python3.10-venv python3.10-doc binutils binfmt-support readline-doc
    The following NEW packages will be installed:
      clang-format clang-format-14 libbsd0 libclang-cpp14 libedit2 libexpat1 libicu70 libllvm14 libmd0 libmpdec3 libpython3-stdlib libpython3.10-minimal libpython3.10-stdlib
      libreadline8 libsqlite3-0 libxml2 media-types python3 python3-minimal python3.10 python3.10-minimal readline-common
    0 upgraded, 22 newly installed, 0 to remove and 5 not upgraded.
    Need to get 36.1 MB/54.1 MB of archives.
    After this operation, 230 MB of additional disk space will be used.
    <snip>
    Setting up clang-format-14 (1:14.0.0-1ubuntu1) ...
    Setting up clang-format:amd64 (1:14.0-55~exp2) ...
    Processing triggers for libc-bin (2.35-0ubuntu3) ..
    
    $ which clang-format
    /usr/bin/clang-format
    
    $ clang-format --version
    clang-format version 10.0.0-4ubuntu1
    
    • Remember clang-format executable location, the path will use for "clang-format.executable" configuration

2. For Your Information

  • Recomend to use npm to install clang-format because the npm install newer version than apt
⚠️ **GitHub.com Fallback** ⚠️