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

Cross-machine communication: cannot open Rdoc

Open klmr opened this issue 7 years ago • 7 comments

I’m now using the Nvim-R-remote configuration. When loading R and then trying to access an R documentation in Vim via \rh, I get this error:

Error detected while processing function ROnJobStdout[7]..ShowRDoc:
line  100:
E484: Cannot open file /nfs/users/nfs_k/kr15/.tmp/Nvim-R/Rdoc

However, the file /nfs/users/nfs_k/kr15/.tmp/Nvim-R/Rdoc is accessible, readable, and contains the expected R documentation text.

My precise configuration is as follows:

.vimrc configuration
" I’m unsure whether this redundancy is necessary but the Nvim-R-remote help also has it.
let R_path = "~/.R/"
let R_app = "launcher.sh"
let R_cmd = "~/.R/launcher.sh"
let $NVIM_IP_ADDRESS = substitute(system("hostname -I"), " .*", "", "")
let R_tmpdir = "~/.tmp/Nvim-R"
.Rprofile configuration
Sys.setenv(R_IP_ADDRESS = trimws(system('hostname -I', intern = TRUE)))
~/.R/launcher.sh
#!/usr/bin/env bash
bsub "NVIMR_ID=$NVIMR_ID \
    NVIMR_SECRET=$NVIMR_SECRET \
    R_DEFAULT_PACKAGES=$R_DEFAULT_PACKAGES \
    NVIM_IP_ADDRESS=$NVIM_IP_ADDRESS \
    $(which R) $@"

klmr avatar Apr 13 '17 11:04 klmr

The help was working in my test here, using two laptops in the same local wifi network. Your vimrc is missing R_compldir, R_remote_tmpdir, and R_nvimcom_home.

jalvesaq avatar Apr 13 '17 12:04 jalvesaq

Hmm, I thought I could continue using the defaults for those since I don’t need to mount a shared file system manually (it worked in the unmerged branch, and from the code it should still work). Does this mean the directories ~/.remoteR/* are now always necessary?

klmr avatar Apr 13 '17 12:04 klmr

The codes should be the same. I "merged" the ip_address branch with the commands (because git branching commands are confusing to me):

git checkout master
git diff master ip_address > /tmp/diff_ip_address
patch -p1 < /tmp/diff_ip_address

Unless the path to your home directory is exactly the same in both machines, you need all the variables because we must ensure that R will save files in a directory that Vim can read. If you have R and nvimcom installed in the local machine and the nvimcom version in the local machine is the same of the remote one, than Vim will run the local nclientserver, and that is OK. But, in my tests, the local machine did not have R installed, so I had to run the nclientserver from the remote machine (but not in the remote machine). Moreover, Nvim-R read the DESCRIPTION of the installed nvimcom to check whether it is necessary to update the package. In sum, it is better to set all variables.

jalvesaq avatar Apr 13 '17 13:04 jalvesaq

Unless the path to your home directory is exactly the same in both machines

It is: both machines mount exactly the same file system for my home directory.

Moreover, Nvim-R read the DESCRIPTION of the installed nvimcom to check whether it is necessary to update the package.

Yes, I noticed that it actually updated nvimcom today (I hadn’t used it for a few days).

I’m gonna start digging around a bit.


For reference, the “merge” here would be:

git checkout master
git merge ip_address

klmr avatar Apr 13 '17 13:04 klmr

Is the Rdoc opening now?

jalvesaq avatar Apr 13 '17 13:04 jalvesaq

I found something: the Rdoc file (/nfs/users/nfs_k/kr15/.tmp/Nvim-R/Rdoc) seems to be created with some delay. So the error message in Vim makes sense: at the time that the error message is issued, the file doesn’t exist yet.

After the first attempt, it seems to work: subsequent requests to open a help page succeed (with the correct contents, i.e. it’s not an old Rdoc file being read). Maybe there’s a timeout somewhere that’s too short?

klmr avatar Apr 19 '17 16:04 klmr

Does adding the following lines below line 2213 of R/common_global.vim fix the problem?

    if !filereadable(s:docfile)
        sleep 1
    endif

jalvesaq avatar Apr 19 '17 22:04 jalvesaq

Please, see https://github.com/jalvesaq/Nvim-R/issues/768

jalvesaq avatar Nov 12 '23 18:11 jalvesaq