vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Lintr issue in R notebook files

Open j-huic opened this issue 2 years ago • 0 comments

So I followed this to get an R notebook running in VS Code (steps 2-4 since I had Jupyter and R already installed). The code in the notebook runs fine, but I keep getting the following error in random places:

"Failed to run diagnostics: callr subprocess failed: Full file exclusions must be character vectors of length 1. items: 1 are not! lintr"

I guess it comes up wherever there is supposed to be a style correction, and it comes up if I make other intentional style errors, like using "=" for assignment instead of "<-". For instance, running lint( ) on this same file returns the following (along with a bunch of other style corrections):

style: [brace_linter] Opening curly braces should never go on their own line and should always be followed by a new line.
{

error: [error] unexpected '['
 "cells": [
          ^

style: [line_length_linter] Lines should not be more than 80 characters.

\u001b[22m\u001b[34mstyle: \u001b[39m[brace_linter] \u001b[1mOpening curly braces should never go on their own line and should always be followed by a new line.\u001b[22m\n",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I do have a .lintr file in my directory, but I had to create one with use_lintr( ) as per this link. The error existed previous to creating this file. Running read.dcf(".lintr") returns this (as a table):

linters	encoding
linters_with_defaults() # see vignette("lintr")	"UTF-8"

This issue does not appear with the R extension disabled, but that's a poor solution since I definitely want its provided features. It also does not appear when I remove the languageserver package but again, I lose intellisense.

Environment:

  • OS: Windows
  • Version: 1.71.1 (user setup) Commit: e7f30e38c5a4efafeec8ad52861eb772a9ee4dfb Date: 2022-09-08T19:56:36.424Z Electron: 19.0.12 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.19044 Sandboxed: No
  • R Version: 4.2.0
  • vscode-R version: 2.5.3

Additional context

The lint(".currentfile") output was extra confusing because:

  1. I don't think the curly braces error refers to my function, since it comes up even without any functions in the file
  2. The second error calls a square bracket out of place, while there are no square brackets in the file
  3. The third error (and a ton of similar ones below it) refer to lines of 80+ characters, when my entire notebook file is three chunks:

I think it's best if I just paste the screenshot here: image There's another two screens worth of messages - after the screenshot runs out, they refer to every single line 52-72 (even though these three chunks are the entire file)

Here's a text file with the whole error message: errormsg_ipynb.txt

Regular .R files in the same directory work fine, it is only the notebook files. I don't think I have an R project set up, since there is no .Rproj file (although I can still use relative paths for files in the same folder), and the parent folder is also the working directory for which I used setwd(). I have no idea how much this matters, but I guess the extra info can't hurt, and I also got ['${workspaceFolder}' can not be resolved from VS Code while I was setting up the extension and the languageserver package, although I opened the workspace folder in VS Code and everything was fine afterwards.

Let me know if I can provide additional info, thanks.

j-huic avatar Sep 14 '22 23:09 j-huic