Skip to content

fix: When running a linter through WSL, the file where the error occu… #531

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yaoyao22fanfan
Copy link

[Unreleased]

Changed

  • fix: When running a linter through WSL, the file where the error occu)rred cannot be correctly indicated #530

@mshr-h mshr-h requested review from mshr-h and Copilot July 30, 2025 05:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where running a linter through WSL (Windows Subsystem for Linux) fails to correctly identify the file where errors occurred. The fix involves converting WSL paths to Windows format and cleaning up NUL characters from the output.

Key changes:

  • Added path conversion from WSL format to Windows format for proper file identification
  • Added cleanup of superfluous NUL characters from linter output
  • Minor code formatting improvements

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/linter/VerilatorLinter.ts Implements WSL path conversion and NUL character cleanup to fix file path resolution
CHANGELOG.md Documents the bug fix in the changelog
Comments suppressed due to low confidence (1)

src/linter/VerilatorLinter.ts:68

  • [nitpick] The function name 'convertFromWslPath' is ambiguous about the direction of conversion. Consider renaming to 'convertWslPathToWindows' to clearly indicate it converts from WSL format to Windows format.
  private convertFromWslPath(inputPath: string): string {

@@ -65,6 +65,11 @@ export default class VerilatorLinter extends BaseLinter {
return child.execSync(cmd, {}).toString().replace(/\r?\n/g, '');
}

private convertFromWslPath(inputPath: string): string {
let cmd: string = `wsl wslpath -w '${inputPath}'`;
return child.execSync(cmd, {}).toString().replace(/\r?\n/g, '');
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The function does not handle potential errors from execSync. If the wslpath command fails, this will throw an exception without a clear error message indicating the WSL path conversion failed.

Suggested change
return child.execSync(cmd, {}).toString().replace(/\r?\n/g, '');
try {
return child.execSync(cmd, {}).toString().replace(/\r?\n/g, '');
} catch (error) {
this.logger.error(`Failed to convert WSL path: ${inputPath}. Error: ${error.message}`);
return inputPath; // Fallback to the original path
}

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant