Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory on Windows #34

Open
agarny opened this issue Dec 30, 2024 · 3 comments
Open

No such file or directory on Windows #34

agarny opened this issue Dec 30, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@agarny
Copy link

agarny commented Dec 30, 2024

Hi,

First, thanks a lot for your WASM-based version of ClangFormat!

I have been able to use it fine from Linux and macOS, but not from Windows. Running the exact same command on all three platforms (e.g. clang-format -i src/libopencor/src/* from a script listed in a package.json file), I get a message that reads No such file or directory on Windows while it all works as expected on Linux and macOS.

I confirmed this by running your CommonJS file from the command line, i.e. something like node ./node_modules/.pnpm/@[email protected]/node_modules/@wasm-fmt/clang-format/clang-format-cli.cjs -i src\libopencor\src\*.* and sure enough I am still getting No such file or directory.

Is that an issue with your WASM-based version of ClangFormat or something that I am missing on Windows?

@magic-akari magic-akari self-assigned this Dec 30, 2024
@magic-akari
Copy link
Member

I'm not on Windows at the moment, but I need to check a couple of things:

  1. Whether it works on specific files, not glob/wildcards, on Windows.
  2. Whether clang-format (the official clang tool) supports glob/wildcards.
  3. Which Windows shell you're using?

I suspect the glob/wildcards you're using are expanded by a Unix-like shell, which your Windows shell doesn't support.
You can investigate this yourself and provide feedback, or wait until I have a chance to verify.

@agarny
Copy link
Author

agarny commented Dec 30, 2024

  1. Whether it works on specific files, not glob/wildcards, on Windows.

Sorry for not mentioning it in the first place, but it doesn't work on specific files either. I, for instance, tried pnpm clang-format -i .\src\libopencor\src\main.cpp and still got No such file or directory. Same story with node ./node_modules/.pnpm/@[email protected]/node_modules/@wasm-fmt/clang-format/clang-format-cli.cjs -i src\libopencor\src\main.cpp.

  1. Whether clang-format (the official clang tool) supports glob/wildcards.

I have just tried the offical clang-format (version 19.1.0) and it works fine using specific files (e.g., ..\clang+llvm-19.1.0-x86_64-pc-windows-msvc\bin\clang-format.exe -i .\src\libopencor\src\main.cpp) or even using a wildcard (e.g., ..\clang+llvm-19.1.0-x86_64-pc-windows-msvc\bin\clang-format.exe -i .\src\libopencor\src\*.cpp). If I do something like ..\clang+llvm-19.1.0-x86_64-pc-windows-msvc\bin\clang-format.exe -i .\src\libopencor\src\*.* then I get is a directory printed twice, which I imagine is for the current and parent directories.

  1. Which Windows shell you're using?

I am using PowerShell.

I suspect the glob/wildcards you're using are expanded by a Unix-like shell, which your Windows shell doesn't support.

I am running your WASM-based version of ClangFormat from a script in a package.json file and wildcards are properly expanded on Linux and macOS, but... not on Windows (using PowerShell at least) as I have just confirmed using a simple script that outputs the arguments it is given. For my original src/libopencor/src/* argument, my test script receives src/libopencor/src/* while, on macOS, it receives src/libopencor/src/main.cpp, src/libopencor/src/version.cpp, and src/libopencor/src/version.h which are indeed the files in src/libopencor/src.

Still, this wildcard issue between Node.js and Windows PowerShell is probably not relevant in the current context. What is clear is that the same arguments passed to your WASM-based version of ClangFormat and to the original ClangFormat don't yield the same outcome.

@magic-akari magic-akari added the bug Something isn't working label Jan 3, 2025
@magic-akari
Copy link
Member

Thank you for your feedback, it helps a lot.

The issue occurs with the logic for locating the .clang-format configuration file.
To bypass this problem, you can add --style=none, --style=Chromium, or --style=file:.clang-format.

However, wildcards are still unsupported because the underlying reason is that the file system was designated as Unix/POSIX during the macro compilation process. While recompiling on Windows might fix it, but it is still foreseeable that it cannot be cross-platform.

Since LLVM allows the implementation of custom file systems, it is possible to fix this bug, but it requires considerable effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants