Open wurli opened 6 months ago
That is interesting, I just opened like 5-6 old projects using renv
and I had no issues. When I open such project, I see that nvimcom is being installed.
Interesting indeed! Have you previously done any additional setup to get renv working with R.nvim?
Nothing I can think of. I just had a look inside one of the renv.lock
file and nvimcom
is not even listed. Humm I am not sure what is goin on!
That's very strange - if renv installs nvimcom, it must have already cached it or be configured to know where to look for it, since nvimcom isn't on CRAN. Either way, I'm 99% sure it won't Just Work™ from a fresh system. Would be great if others could test and confirm 🙏
I've had this problem before and just tested it now. I bypass renv by setting export R_PROFILE_USER="~/.Rprofile"
in my .zshrc
, which bypasses the project .Rprofile
and essentially deactivates renv.
The reason for this is that with R_PROFILE_USER
unset, renv loads, and tries to install R packages but loading my ~/.Rprofile
first. I have a messy .Rprofile
which has library calls to remotes
and rlang
which breaks the renv process. I'm sure I could fix this by tidying my .Rprofile
.
If I open a renv project without R_PROFILE_USER
and no ~/.RProfile
everything works fine for me, nvimcom compiles and R.nvim loads with no issues.
I can confirm that R.nvim works fine with {renv} with no issue. The only step needed is to completely exit Neovim after renv::init()
and open Neovim again. {nvimcom} will be installed in renv
folder but will not appear in renv.lock
.
Can we close this? I am using renv
all the time and I am facing no issues. @wurli are you experiencing any current problems with renv
?
@PMassicotte I believe I am facing the same issue. rnvimserver
dumps core upon first interaction with a renv
enabled project. I could not replicate this in my journal for scripts or projects that do not use renv
. Also, as @wurli suggested, this problem occurs only after a fresh boot. If I were to first open a regular project and then move on to one with renv
enabled then everything works great.
What is the value of
setwd = "nvim",
:echo getcwd()
in Neovim's command mode and getwd()
in R console both point to my renv project's directory namely "/home/nand1sh/Study/LWE_RESEARCH"
.
Do you use built-in terminal or something else?
Yes, I use the built in terminal for R in R.nvim.
That is interesting. I can not reproduce the problem at the moment. When I open a renv
project for the first time, I see that nvimcom
is being installed (takes 2–3 seconds). Then I am ready to go. Do you have any logs to share?
Hey, this helps! If I wait for a few seconds and then start R, I get no issues. Only if I start R immediately after opening a .R file in a renv
enabled project do I get this-
Jul 31 16:30:43 archlinux systemd-coredump[1096]: Process 1059 (rnvimserver) of user 1000 terminated abnormally with signal 11/SEGV, processing...
Jul 31 16:30:43 archlinux systemd[1]: Created slice Slice /system/systemd-coredump.
Jul 31 16:30:43 archlinux systemd[1]: Started Process Core Dump (PID 1096/UID 0).
Jul 31 16:30:43 archlinux systemd-coredump[1097]: [🡕] Process 1059 (rnvimserver) of user 1000 dumped core.
Stack trace of thread 1059:
#0 0x00007a498ab79fad pthread_cancel (libc.so.6 + 0x90fad)
#1 0x00005a7681e249bb n/a (/home/nand1sh/Study/LWE_RESEARCH/renv/library/linux-arch-rolling/R-4>
#2 0x0000000000000000 n/a (n/a + 0x0)
ELF object binary architecture: AMD x86-64
Jul 31 16:30:43 archlinux systemd[1]: systemd-coredump@0-1096-0.service: Deactivated successfully.
However, unlike you I do not get a prompt saying that nvimcom
is being installed. Is it because I have the --quiet
argument enabled for R.nvim?
The R_args
config option is used only to launch R in the terminal emulator for interactive use. The message that nvimcom
is being installed is always displayed with vim.api.nvim_echo()
(see scripts/before_rns.R
, line 115, and lua/r/server.lua
, line 73).
Hey, this helps! If I wait for a few seconds and then start R, I get no issues. Only if I start R immediately after opening a .R file in a
renv
enabled project do I get this-Jul 31 16:30:43 archlinux systemd-coredump[1096]: Process 1059 (rnvimserver) of user 1000 terminated abnormally with signal 11/SEGV, processing... Jul 31 16:30:43 archlinux systemd[1]: Created slice Slice /system/systemd-coredump. Jul 31 16:30:43 archlinux systemd[1]: Started Process Core Dump (PID 1096/UID 0). Jul 31 16:30:43 archlinux systemd-coredump[1097]: [🡕] Process 1059 (rnvimserver) of user 1000 dumped core. Stack trace of thread 1059: #0 0x00007a498ab79fad pthread_cancel (libc.so.6 + 0x90fad) #1 0x00005a7681e249bb n/a (/home/nand1sh/Study/LWE_RESEARCH/renv/library/linux-arch-rolling/R-4> #2 0x0000000000000000 n/a (n/a + 0x0) ELF object binary architecture: AMD x86-64 Jul 31 16:30:43 archlinux systemd[1]: systemd-coredump@0-1096-0.service: Deactivated successfully.
However, unlike you I do not get a prompt saying that
nvimcom
is being installed. Is it because I have the--quiet
argument enabled for R.nvim?
I am using auto-open in my config, so it is likely waiting for the initialization to be done before loading R. My guess is that you just have to wait 2-3 seconds before opening the terminal in an renv
project.
I see. Thanks for the clarification @jalvesaq and @PMassicotte!
NB, this issue has previously been discussed at jalvesaq/Nvim-R/issues/445.
Problem description
When a project uses {renv}, {nvimcom} is not available, meaning a good deal of R.nvim breaks. The reason for this is that in {renv} projects the
.libPaths()
are reset, meaning R can no longer find {nvimcom}, which will have been installed by R.nvim into the libpath where most other package installations also live.Current workaround
The workaround people seem to have been using is to:
nvimcomlib
nvimcom
installationRENV_CONFIG_EXTERNAL_LIBRARIES
environmental variable to point to this new libpath, which tells {renv} it can also look for package installations hereThere are a few issues with this workaround:
Suggested approach for seamless {renv} support
R_LIBS
environmental variable before R starts upRENV_CONFIG_EXTERNAL_LIBRARIES
environmental variable to the same value, thereby making {nvimcom} available in {renv} projectsI'm not that familiar with with what happens when R.nvim is installed, so I don't know how realistic/well informed this approach is. However, {renv} is pretty widely used - a quick GitHub search reveals 9.1k repos with a
renv.lock
file - so in my humble opinion, it's worth seriously considering adding official support.