jalvesaq / Nvim-R

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

`"nvimcom_msg_to_nvim" not available for .C() for package "nvimcom"` error ~~for `slidy_presentation`~~ if nvimcom is unloaded #779

Closed iago-pssjd closed 11 months ago

iago-pssjd commented 1 year ago

Hi,

When I render an RMarkdown with output: slidy_presentation in the YAML header, it seems to be rendered fine, but it ends with:

Output created: RCourse.html
Error in .C("nvimcom_msg_to_nvim", paste0("ROpenDoc('", res, "', '", brwsr,  : 
  "nvimcom_msg_to_nvim" not available for .C() for package "nvimcom"
In addition: Warning message:
In sink() : no sink to remove
jalvesaq commented 1 year ago

Are you calling the help() function in your slides? Could you try this in your vimrc:

let R_nvimpager = 'no'

or in your init.lua:

vim.g.R_nvimpager = 'no'
iago-pssjd commented 1 year ago

Are you calling the help() function in your slides?

It appears, but in chunks with eval = FALSE, so actually not.

iago-pssjd commented 1 year ago

I get the same with

let R_nvimpager = 'no'
jalvesaq commented 1 year ago

I need a minimum .Rmd to try to replicate the bug here. Could you post one, please?

iago-pssjd commented 1 year ago

I do not have time currently for preparing such, give me a week or two.

jalvesaq commented 11 months ago

Any news on this issue? The function nvimcom_msg_to_nvim() is in src/nvimcom.c (since October 26, 2023), so the only way of not finding it is if the version of nvimcom installed in R is not the current version (the one in the Nvim-R subdirectory R/nvimcom). But, in this case, a warning on mismatching versions should have been displayed, and you should be able to display it again with the :messages command.

iago-pssjd commented 11 months ago

Thanks for asking.

First, the lines

In addition: Warning message:
In sink() : no sink to remove

were due to a sink() evaluation through the document, so this has nothing to do.

Second, the issue is not only the presence of the Error message after rendering the Rmd, but when trying to render it again it appears an error saying could not find function "nvim.interlace.rmd", so one needs to close and start R again.

Third, the issue happens also with Nvim-R just updated.

A reprex of the issue is the next Rmd file:

---
title: "Reprex"
output: slidy_presentation
---

```{r, echo=TRUE, eval=TRUE, include=FALSE}

lapply(paste('package:', names(sessionInfo()$otherPkgs), sep = ""), detach, character.only = TRUE, unload = TRUE)
jalvesaq commented 11 months ago

You are detaching all non-base packages, which includes nvimcom. Once detached, none of its functions is available. The only way to fix this would be to write a real front-end to R.

iago-pssjd commented 11 months ago

Thanks! Good point. And great! Not an issue and easy solution