Skip to content

Update format shell script for WSL compat#422

Open
Phlosioneer wants to merge 1 commit intopret:masterfrom
Phlosioneer:update-format-sh-for-wsl
Open

Update format shell script for WSL compat#422
Phlosioneer wants to merge 1 commit intopret:masterfrom
Phlosioneer:update-format-sh-for-wsl

Conversation

@Phlosioneer
Copy link

The script now looks for clang-format-18, which is needed for WSL Ubuntu, rather than the standard clang-format.

The script now looks for `clang-format-18`, which is needed for WSL
Ubuntu, rather than the standard `clang-format`.
@red031000
Copy link
Member

clang-format works fine for me in wsl
I'd rather pin it to a higher version if we can though, cause if ubuntu updates clang format version, this will break
it also breaks across ubuntu versions

@Phlosioneer
Copy link
Author

Dang, that makes this tricky. I followed the instructions in the contributing guide; apt install clang-format on wsl Ubuntu installed version 10, while apt install clang-format-18 installed version 18.

Let me see if I can add a --version check instead of just checking for executable existence.

@red031000
Copy link
Member

out of curiosity what version of wsl ubuntu do you have?

@Phlosioneer
Copy link
Author

WSL 2, Ubuntu 20.04.4 LTS

@red031000
Copy link
Member

yeah that would explain it.... have you considered updating to at least 24.04

@Phlosioneer
Copy link
Author

I was able to update to 22, but 24 is giving me a lot of trouble during the upgrade. I figured a way to check --version, I'll commit and push after lunch.

@red031000
Copy link
Member

what clang-format version does 22 give you btw?

@Phlosioneer
Copy link
Author

14

@Phlosioneer
Copy link
Author

Well this is unfortunate. Ubuntu 22 doesn't have an apt package for clang-format-18 or higher. Now I'm going to have to figure out how to finish the upgrade to 24...

set -e

find src include \( -name "*.c" -or -name "*.cpp" -or -name "*.h" -or -name "*.hpp" \) -exec clang-format -i --verbose {} +
if [ $(which clang-format-18) ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ $(which clang-format-18) ]; then
if which clang-format-18 &>/dev/null; then

or

Suggested change
if [ $(which clang-format-18) ]; then
if command -v clang-format-18 &>/dev/null; then


find src include \( -name "*.c" -or -name "*.cpp" -or -name "*.h" -or -name "*.hpp" \) -exec clang-format -i --verbose {} +
if [ $(which clang-format-18) ]; then
# WSL and old Ubuntu versions have clang-format frozen on version 10. We need at
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we can specify a minimum supported distro, or ask that users symlink clang-format-xxx to their PATH, eliminating the need to change this file

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

This pull request has had no activity for 60 days and will be marked stale. If there is no further activity, it will be closed in 30 days.

@github-actions github-actions bot added the stale label Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants