jalvesaq / Nvim-R

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

Suppress "is not writable" message if don't want a user-writable R directory #735

Closed trevorld closed 1 year ago

trevorld commented 1 year ago

I attempted to manually create a vimcom_info file in ~/.cache/Nvim-R but this doesn't suppress the inital "is not writable" message.

R_compldir <- "~/.cache/Nvim-R"
vimcom_info <- file.path(R_compldir, "vimcom_info")

version <- packageVersion("nvimcom") |> as.character()
home <- system.file(package = "nvimcom")
Rversion <- getRversion() |> as.character()

cat(version, home, Rversion, sep = "\n", file = vimcom_info)
jalvesaq commented 1 year ago

The message is displayed when the script R/before_ncs.R exits with error code 71. This should not happen if nvimcom is installed, its version isn't outdated and R's version is the same used to build nvimcom.

trevorld commented 1 year ago
jalvesaq commented 1 year ago

You are right. I will change it to check only major version changes. Thanks for the suggestion!

maitra commented 8 months ago

How do you install nvimcom systemwide? I would use devtools::install_github("jalvesaq/nvimcom") but that package appears deprecated.

trevorld commented 8 months ago

How do you install nvimcom systemwide? I would use devtools::install_github("jalvesaq/nvimcom") but that package appears deprecated.

In the terminal I go into the cloned repo and in my (bash) shell enter:

cd R/nvimcom
sudo Rscript -e "devtools::install()"

The more up-to-date alternative to devtools::install_github() would be remotes::install_github("jalvesag/nvimcom", subdir = "R/nvimcom") (since the R package code is in a subdirectory of this repo...)

maitra commented 8 months ago

How do you install nvimcom systemwide? I would use devtools::install_github("jalvesaq/nvimcom") but that package appears deprecated.

In the terminal I go into the cloned repo and in my (bash) shell enter:

cd R/nvimcom
sudo Rscript -e "devtools::install()"

The more up-to-date alternative to devtools::install_github() would be remotes::install_github("jalvesag/nvimcom", subdir = "R/nvimcom") (since the R package code is in a subdirectory of this repo...)

Thanks! I tried this, but I get:

> remotes::install_github("jalvesag/nvimcom", subdir = "R/nvimcom")
Error: Failed to install 'unknown package' from GitHub:
  HTTP error 404.
  Not Found

  Did you spell the repo owner (`jalvesag`) and repo name (`nvimcom`) correctly?
  - If spelling is correct, check that you have the required permissions to access the repo.
maitra commented 8 months ago

Got it! It should be:

remotes::install_github("R-nvim/R.nvim", subdir = "nvimcom")

maitra commented 8 months ago
  • Is there any way to suppress the "/path/to/user/R/directory" is not writable. Create it now? [y/n] message? Every time I open an R file in vim I need to press n and this is a bit annoying

    • I do not have a user-writable R directory and do not want one (I prefer to install my R packages sitewide as a root user)

    • I have already installed {nvimcom} site-wide by finding the {nvimcom} package code within the Nvim-R source and manually installing it site-wide

    • After pressing an initial "n" the plugin seems to run fine (i.e. I can start R sessions in vim and send code to them with the plugin)

I attempted to manually create a vimcom_info file in ~/.cache/Nvim-R but this doesn't suppress the inital "is not writable" message.

R_compldir <- "~/.cache/Nvim-R"
vimcom_info <- file.path(R_compldir, "vimcom_info")

version <- packageVersion("nvimcom") |> as.character()
home <- system.file(package = "nvimcom")
Rversion <- getRversion() |> as.character()

cat(version, home, Rversion, sep = "\n", file = vimcom_info)

This interactive message appears to be back. All my plugins are all up to date. How do I get rid of this message?

jalvesaq commented 8 months ago

The message should appear only if Nvim-R tries to install nvimcom, which should happen only if nvimcom is outdated. So, the solution is to manually build and install nvimcom:

cd /tmp
R CMD build /path/to/Nvim-R/R/nvimcom
sudo R CMD INSTALL nvimcom_0.9-163.tar.gz
maitra commented 8 months ago

Thanks! I had forgotten that updating the plugins for nvim and the nightly packages from CRAN does not update the R package nvimcom from github. Also updating nvimcom makes the error go away. Thank you again!