jalvesaq / Nvim-R

Vim plugin to work with R
GNU General Public License v2.0
968 stars 125 forks source link

Loading `sets` library breaks Nvim-R #742

Closed mschilli87 closed 1 year ago

mschilli87 commented 1 year ago

If I create a file test.R with

library(sets)

and open it in neovim (v0.9.1), I get an error in the statusbar prompting me to run RDebugInfo which throws

RInitOut
RInitErr
 Attaching package: ‘nvimcom’
The following object is masked from ‘package:utils’:      vi
Error in as.environment(pos) :    no item called "package:sets" on the search list Calls: <Anonymous> -> nvim.buildomnils -> nvim.bol -> objects Execution halted

If in the above example, I replace sets by any other installed libary, everything works as expected.

In case it is relevant, sets is the last library I installed.

The R package versions are nvimcom_0.9-146 & sets_1.0-24.

jalvesaq commented 1 year ago

I can replicate the issue. As a workaround, after starting R without library(sets) in the script, you can run the following command:

nvimcom:::nvim.buildomnils("sets")

I expected the above command to result in failure, but, because it works without error, I cannot replicate the bug interactively, and it will be hard to fix.

mschilli87 commented 1 year ago

Thank you for the quick reply. I opened a script without library(sets) in neovim, started an R session and ran the command you suggested. Unfortunately(?) for me it does fail, AFAICT reproducing the exact same error:

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin22.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> nvimcom:::nvim.buildomnils("sets")
echo 'Building completion list for "sets"'
Error in as.environment(pos) : 
  no item called "package:sets" on the search list

Since the workaround command failed, opening a script loading the sets library still results in the same error for me.

Is there any way I can help further troubleshooting this?

jalvesaq commented 1 year ago

The string "sets" was matching "datasets". The workaround worked for me because I don't load the "datasets" package. The bug should be fixed by the next commit.

mschilli87 commented 1 year ago

I can confirm that updating Nvim-R fixed the issue. Thank you for the fast responses and fix. ❤️