Skip to content

R linter fails with normalizePath() empty path error in callr subprocess #1630

@matgir99

Description

@matgir99

Describe the bug
The R linter fails with a normalizePath() error when trying to lint R files, showing "path[1]="": Impossibile trovare il percorso specificato" (Cannot find the specified path). The error occurs in a callr subprocess and prevents the linter from running, even though the R code itself has no linting issues when run directly.

To Reproduce
Steps to reproduce the behavior:

  • Create an R file (e.g., setup_r_dependencies.R) with valid R code
  • Open the file in VS Code with the R extension enabled
  • The extension automatically attempts to run diagnostics
  • See error in the Problems panel: Failed to run diagnostics: ! in callr subprocess. Caused by error in lintr::lint(path, cache = cache, text = content): ! Linter linter() failed in '': Caused by error in normalizePath(): ! path[1]="": Impossibile trovare il percorso specificato

Can you fix this issue by yourself? (We appreciate the help)

No - this appears to be an internal issue with how the extension handles file paths when calling the lintr subprocess.

(If applicable) Please attach setting.json

// Default R extension settings - no custom configuration
"r.rterm.windows": "",
"r.rterm.mac": "/usr/local/bin/R",
"r.rterm.linux": "/usr/bin/R",
"r.rterm.option": [],
"r.source.encoding": "UTF-8",
"r.source.focus": "editor",
"r.alwaysUseActiveTerminal": false,
"r.bracketedPaste": false,
"r.sessionWatcher": true,
"r.rtermSendDelay": 8,

Expected behavior
The linter should run without errors and provide appropriate linting feedback. When running lintr::lint('setup_r_dependencies.R') directly in R, it works correctly and reports "No lints found."

Environment (please complete the following information):

OS: Windows
VSCode Version: [your VS Code version]
R Version: 4.5.0 (2025-04-11 ucrt)
vscode-R version: [your extension version]

Additional context

The error message is in Italian, suggesting it may be related to locale handling: "Impossibile trovare il percorso specificato" = "Cannot find the specified path"
Direct testing shows the issue is isolated to the VS Code extension's linter integration:

  • (ok) lintr::lint('setup_r_dependencies.R') works fine in R console
  • (ok) callr::r(function() { lintr::lint('setup_r_dependencies.R') }) works fine in R console
  • (bug) VS Code extension fails with empty path error
    The error suggests the extension is passing an empty string (path[1]="") to normalizePath(), indicating a path resolution bug in the extension's linter integration
    File has proper encoding headers and no unusual characters
    No R configuration files (.Rprofile, .Renviron) that could interfere
    The R code itself is syntactically correct and functional
    The core issue appears to be that the extension is somehow passing an empty file path string to the lintr subprocess, causing normalizePath() to fail.
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions