Vscode-r: Failed to run diagnostics lintr

Created on 25 May 2020  路  12Comments  路  Source: Ikuyadeu/vscode-R

Describe the bug
I couldn't decide if this was a languageserver issue or not, sorry. Every time I open a new file, the top line shows the error Failed to run diagnostics: lintr.

Expected behavior
I expect the files lints to be correctly checked and any issues display in the problems tab.

Environment (please complete the following information):

  • OS: macOS
  • Version: 1.45.1
    Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
    Date: 2020-05-14T08:33:47.663Z
    Electron: 7.2.4
    Chrome: 78.0.3904.130
    Node.js: 12.8.1
    V8: 7.8.279.23-electron.0
    OS: Darwin x64 19.4.0
  • R Version: 3.6.3
  • vscode-R version: 1.3.0

    • languageserver version: 0.3.5

    • lintr version: 2.0.1

Additional context
I see the following in the diagnostics but I am not sure if it is related.

diagnostics_task: <callr_status_error: callr subprocess failed: attempt to apply non-function>
 in process 
-->
<callr_remote_error in linters[[linter]](expr):
 attempt to apply non-function>
 in process 78394 

I know this is all very vague, please let me know if you need any additional information.

bug

All 12 comments

Do you have any .lintr file config to be applied to the document you are editing? Looks like it is trying to use a lintr function that is specified but does not exist.

This is also likely that there's something wrong with lintr package working with the document you are editing due to some subtle bugs in lintr triggered by malformed code (e.g. https://github.com/jimhester/lintr/issues/461). In https://github.com/REditorSupport/languageserver/pull/220, we make all such lintr failure explicit or otherwise the diagnostics will be silently no error as the background process ends up in an error without any lintr result.

Would you like to reduce your document and find the minimal content that could reproduce such error?

Just to add that you can see if it is lintr (rather than the vscode extension) by manually calling lintr yourself

(from the R console)

library(lintr)
lint("./path_to_file/file_to_lint.R")
lint("./R/select.R")                                                                                                                                          
# Error in linters[[linter]](expr) : attempt to apply non-function

Interesting. I have a valid .lintr file, and I tried reinstalling lintr but no joy. How very odd.

FYI, I had some issues with the withr file was corrupt telling me that withr.rdb was corrupt. I deleted the package and managed to install the latest version of lintr from GitHub along with a new version of lintr but I still get this same issue so it can't be that.

If your lintr works with other scripts but this one, it is then most likely to be caused by some lintr bug trying to deal with malformed code.

Would you like to try parse("./R/select.R") and see if the code could be parsed without an error?

And would you like to experiment by reducing code blocks in ./R/select.R and see what's the minimal code block that could reproduce this error?

Ah this is a problem with every file in my package, sorry. It's not just one file playing up, this happens every time I open a .R file, it tries to run lintr against it but I get the diagnostic error I showed in my initial post. I will try to parse the script when I get a chance later and let you know how I get on.

FYI there were no issues parsing the file, nor any other files.

Not sure what a solution is but you can disable lintr to suppress the error message I think by setting this setting in your json settings file :

"r.lsp.diagnostics": false

@nathaneastwood Would you like to use the following to show the traceback:

options(error = function() traceback(3))

and see what happens when you run lint("./R/select.R").

It looks like your .lintr is not really valid I guess?

Ok, so I decided to delete my .lintr file and recreate it. Now it would appear to be working. I know I tried this the other day with no joy so I am wondering if between the reinstallation of lintr and the recreation of the .lintr file it has been solved. I cannot pinpoint the solution exactly but thank you very much for your suggestions!

I now have another issue where functions defined within my package (and therefore my VSCode workspace) are not being detected.

no visible global function definition for '...' object_usage_linter

where ... here represents the several functions which show this. Any thoughts? (I've tried both library() and devtools::load_all())

@nathaneastwood The object_usage_linter seems problematic, see https://github.com/jimhester/lintr/issues/482.

Ah, no problem. Let's close this issue for now then. Thanks very much for all your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tdeenes picture tdeenes  路  5Comments

MaTo04 picture MaTo04  路  5Comments

LePeti picture LePeti  路  4Comments

nathaneastwood picture nathaneastwood  路  6Comments

Victsz picture Victsz  路  5Comments