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

strange errors when loading package from nvim.bol

Open zkamvar opened this issue 2 years ago • 9 comments

I use Nvim-R for all my package development needs, but ~ 3 months ago (maybe longer), I started noticing this error popping up whenever I would load a package:

> devtools::load_all("/path/to/carpentries/sandpaper") # [history skip]                                                                                          
ℹ Loading sandpaper
Error in if (info == "\006\006") { : argument is of length zero
Error in if (info == "\006\006") { : argument is of length zero
In addition: Warning message:
In nvim.bol(paste0(bdir, "omnils_", p, "_", pvi), p, TRUE) :
  Error while generating omni completion line for: .store (package:sandpaper, sandpaper).

warning messages from top-level task callback 'NVimComHandler'
Warning message:
In nvim.bol(paste0(bdir, "omnils_", p, "_", pvi), p, TRUE) :
  Error while generating omni completion line for: GITIGNORED (package:sandpaper, sandpaper).

I'm not sure what the omni completion lines are, but maybe you might know what may be causing this. For what its worth, here are my .vimrc configurations for Nvim-R

zkamvar avatar Nov 20 '21 00:11 zkamvar

I don't use devtools to be able to replicate the issue, but the message means that info has length zero. I accidentally pushed a commit that I wanted to put in a new branch... But, since it's already in the master branch, could you, please, update the plugin and do in a terminal emulator (delete all files cached by Nvim-R):

rm ~/.cache/Nvim-R/*

Please, fix the path ~/.cache/Nvim-R/ if necessary. Then, check if omni completion works...

jalvesaq avatar Nov 20 '21 00:11 jalvesaq

I've removed all of the files from the cache, but I still get the same error.

I think the issue may be functions delayed assignment of values. For example, the first error refers to the .store list of functions that is generated from a function. This is what the corresponding line in the omnil file looks like:

.store[listsandpaper4

The GITIGNORED variable is dynamically loaded via delayedAssign() when the package is loaded and doesn't make it to the omnils file.

zkamvar avatar Nov 22 '21 15:11 zkamvar

I have installed devtools and tried to replicate the issue, but sandpaper depends on another package that isn't on CRAN. Do you have a simpler example?

jalvesaq avatar Nov 23 '21 11:11 jalvesaq

I've created a small example that demonstrates both the function factory and delayed assign variable in https://github.com/zkamvar/znktest

> devtools::load_all("/home/zhian/Documents/Git/znktest") # [history skip]                      
ℹ Loading znktest
Error in if (info == "\006\006") { : argument is of length zero
Error in if (info == "\006\006") { : argument is of length zero
In addition: Warning message:
In nvim.bol(paste0(bdir, "omnils_", p, "_", pvi), p, TRUE) :
  Error while generating omni completion line for: .store (package:znktest, znktest).

warning messages from top-level task callback 'NVimComHandler'
Warning message:
In nvim.bol(paste0(bdir, "omnils_", p, "_", pvi), p, TRUE) :
  Error while generating omni completion line for: LOAD_TIME (package:znktest, znktest).


zkamvar avatar Dec 01 '21 16:12 zkamvar

I get the warning message:

Error building omnils_ file. Run :RDebugInfo for details.

And :RDebugInfo gives:

Error: $ operator is invalid for atomic vectors
In addition: Warning message:
In utils::packageDescription(p) : no package 'znktest' was found
Execution halted

jalvesaq avatar Dec 01 '21 16:12 jalvesaq

After manually installing the znktest package and restarting Neovim and R, I no longer get any error message after devtools::load_all("/tmp/znktest"), but omni completion does not work for znktest functions, such as set_this_lesson. And the package appears as not having any function in the Object Browser.

jalvesaq avatar Dec 01 '21 16:12 jalvesaq

If it helps: my usage pattern is:

  1. vim R/zzz.R
  2. <leader>rf
  3. devtools::load_all()

If the package has not previously been loaded or NVim-R has been updated, then I get the error I showed above. After that, I get [ClientServer] Error in omnils file: znktest when I run devtools::load_all()

zkamvar avatar Dec 01 '21 17:12 zkamvar

Is Nvim-R up to date?

jalvesaq avatar Dec 01 '21 17:12 jalvesaq

I am up to date on the "stable" branch, but the same error occurs if I switch to the default branch.

zkamvar avatar Dec 01 '21 18:12 zkamvar

The length of info is always checked in the branch pipe_data_frame. If this issue is still relevant to you, could you try the branch, please?

jalvesaq avatar Oct 26 '22 16:10 jalvesaq

I've checked it and it works for me. Thank you!

zkamvar avatar Oct 26 '22 23:10 zkamvar