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

Failed to run diagnostics lintr #343

Closed
nathaneastwood opened this issue May 25, 2020 · 32 comments
Closed

Failed to run diagnostics lintr #343

nathaneastwood opened this issue May 25, 2020 · 32 comments
Labels

Comments

@nathaneastwood
Copy link

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.

@renkun-ken
Copy link
Member

renkun-ken commented May 25, 2020

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. r-lib/lintr#461). In REditorSupport/languageserver#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?

@gowerc
Copy link
Contributor

gowerc commented May 25, 2020

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")

@nathaneastwood
Copy link
Author

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.

@nathaneastwood
Copy link
Author

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.

@renkun-ken
Copy link
Member

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?

@nathaneastwood
Copy link
Author

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.

@nathaneastwood
Copy link
Author

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

@gowerc
Copy link
Contributor

gowerc commented May 28, 2020

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

@renkun-ken
Copy link
Member

@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?

@nathaneastwood
Copy link
Author

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())

@renkun-ken
Copy link
Member

@nathaneastwood The object_usage_linter seems problematic, see r-lib/lintr#482.

@nathaneastwood
Copy link
Author

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

@DrakoPOD
Copy link

DrakoPOD commented Nov 20, 2022

@nathaneastwood

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!

Can you provide the settings in your .lintr? I already tryed what you said, but I still get the same error:

Failed to run diagnostics: ! in callr subprocess.
Caused by error: 
! Full file exclusions must be character vectors of length 1. items: 1 are not! lintr

@nathaneastwood
Copy link
Author

Unfortunately I no longer have access to the laptop I had this issue on, sorry.

@Falven
Copy link

Falven commented Jan 21, 2023

Happens with:

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

and a jupyter notebook.

@Falven
Copy link

Falven commented Jan 21, 2023

I noticed for R Jupyter notebooks it happens whenever you have a comment that exceeds the gutter size. If you break up the long comments into multiple lines, the errors go away.

@kdzhang
Copy link

kdzhang commented Apr 6, 2023

Probably related to #1198

@cworld1
Copy link

cworld1 commented Apr 13, 2023

I noticed for R Jupyter notebooks it happens whenever you have a comment that exceeds the gutter size. If you break up the long comments into multiple lines, the errors go away.

But it also shows as I assign any variable:

image

Or just one small comment:

image

It looks in a mess and I just follow the .lintr file creation, and nothing have made any change on that.

@renkun-ken
Copy link
Member

Should be fixed via REditorSupport/languageserver#610.

@cworld1
Copy link

cworld1 commented Apr 24, 2023

Thank you! It works very well!

If there's anybody find it wrong like me, just try update languageserver package using the latest development build below:

install.packages("languageserver", repos = c(
    reditorsupport = "https://reditorsupport.r-universe.dev",
    getOption("repos")
))

@matthutchings
Copy link

I am having the same issue as @cworld1, as in the first variable I declare or the first function I call in a notebook cell, I get Failed to run diagnostics: ! in callr subprocess. This is however caused by a different error: ! object 'R_user_dir' is not exported by 'namespace:tools' lintr.

image

This also happens in a .R file, but running lintr::lint on this file in a terminal gives no issues.

I have tried both deleting .lintr and regenerating it with lintr::use_lint(), but no luck.

languageserver version is 0.3.15 and lintr version is 3.0.2.

@renkun-ken
Copy link
Member

@matthutchings Would you like to try the latest development version of languageserver via

install.packages("languageserver", repos = c(
    reditorsupport = "https://reditorsupport.r-universe.dev",
    getOption("repos")
))

@matthutchings
Copy link

Sorry @renkun-ken, I should have mentioned that I have already tried installing the latest dev version.

@KatlehoJordan
Copy link

After installing the latest version of the language server, I am still having this issue:

image

I'm running r in a jupyter notebook on a VS Code dev container.

CPUs Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (8 x 1992)
GPU Status 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled
Load (avg)  
Memory (System) 7.90GB (0.63GB free)
Process Argv ds-playground/ --crash-reporter-id 0035e842-412c-44d1-a8d3-4d2b52fb8945
Screen Reader no
VM 0%
Extension Author (truncated) Version
vscode-neovim asv 0.0.97
vscode-drawio hed 1.6.6
jupyter-keymap ms- 1.1.2
remote-containers ms- 0.295.0
pdf tom 1.2.2
vscode-icons vsc 12.4.0
black-formatter ms- 2023.2.0
isort ms- 2022.8.0
pylint ms- 2023.4.0
python ms- 2023.10.1
vscode-pylance ms- 2023.6.21
jupyter ms- 2023.5.1001582324
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.15
vscode-jupyter-cell-tags ms- 0.1.8
vscode-jupyter-slideshow ms- 0.1.5
autodocstring njp 0.6.1
r-debugger RDe 0.5.4
r REd 2.8.1
intellicode-api-usage-examples Vis 0.2.7
vscodeintellicode Vis 1.2.30

@gonzarizzo
Copy link

I have the same issue running vscode on a conda environment created in Debian running on WSL.

image

The problem is caused in a file.R.git

image

Could you make the developer version available through conda-forge?

Thank you,
Gonzalo

@benz0li
Copy link
Contributor

benz0li commented Aug 2, 2023

Would you like to try the latest development version of languageserver via

install.packages("languageserver", repos = c(
    reditorsupport = "https://reditorsupport.r-universe.dev",
    getOption("repos")
))

I tried. It resolves the issue

Failed to run diagnostics: ! in callr subprocess.
Caused by error: 
! Linter 'object_length_linter' failed in : path[1]="": No such file or directory

I had when working with Jupyter Notebooks in Code.


Environment:

  • OS: Debian 12 (bookworm)
  • code-server version: 4.16.1 (aka Code 1.80.2)
  • R version: 4.3.1
  • vscode-R version: 2.8.1

👉 Issue can be reproduced at https://demo.jupyter.b-data.ch and is resolved by installing the version from R-universe at user level.


@renkun-ken Will there soon be an updated version on CRAN or should I install from R-universe until further notice?

@osmano807
Copy link

I'm still affected by this issue using rev 1e71561a41ef59126273f16bbb466c0b30a2aa64 with a Windows VSCode and Linux Jupyter Lab server.

@Tal500
Copy link
Contributor

Tal500 commented Aug 9, 2023

@renkun-ken I want to mention the same error happens to me when I browsing GIt diff of a file in VSCode UI.
It seems that for such diff files view, the URI that is given to the languageserver of this "file" is of the form git:PATH?{%22path%22:%22PATH%%22,%22ref%22:%22HEAD%22}. Probably the lintr package raise errors for such paths.
Notice that this issue is a one for the package languageserver itself of course. Maybe the good logic is to not pass to lintr paths that are "ill-formed"? Or to emulate them by a temporary file.

@scholarazwa
Copy link

If you have issues with .linter file not being recognised, what works for me is:

  • In your .linter file, after making sure the last bracket is next to the last line of options and added a newline to the end of the file, save it as UTF-8. In Sublime Text there is an option 'Reopen with Encoding', then choose UTF-8 then save the .linter file. It should now work.

@gonzarizzo
Copy link

I have the same issue running vscode on a conda environment created in Debian running on WSL.

image

The problem is caused in a file.R.git

image

Could you make the developer version available through conda-forge?

Thank you, Gonzalo

I have solved this issue by adding .R.git files to the files exclusions.

To do so you have to follow the next steps:

  1. Open visual studio code
  2. Click Settings icon in the left bottom and click Settings
  3. In the search box, search for Files: Associations (Copy-paste this)
  4. Click [Add Item] button and enter **/*.R.git for key, text for value.

This is how it looks:

image

You can add the following lines to your settings.json file, and will have the same results.

"files.associations": {
        "**/*.R.git": ""
    }

@Tal500
Copy link
Contributor

Tal500 commented Oct 2, 2023

I have the same issue running vscode on a conda environment created in Debian running on WSL.
image
The problem is caused in a file.R.git
image
Could you make the developer version available through conda-forge?
Thank you, Gonzalo

I have solved this issue by adding .R.git files to the files exclusions.

To do so you have to follow the next steps:

1. Open visual studio code

2. Click Settings icon in the left bottom and click `Settings`

3. In the search box, search for `Files: Associations` (Copy-paste this)

4. Click [Add Item] button and enter `**/*.R.git` for key, `text` for value.

This is how it looks:

image

You can add the following lines to your settings.json file, and will have the same results.

"files.associations": {
        "**/*.R.git": ""
    }

This solution is problematic, since now you're giving up on basic language feature of R in git-historical/diff version on VSCode, so that even basic syntax highlighting would not work not in these git View stuff.

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

No branches or pull requests

15 participants