jalvesaq / Nvim-R

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

Error: Missing quote and others when debugging function called from shiny::runApp() #655

Closed rcst closed 2 years ago

rcst commented 2 years ago

First of, I'm using Nvim-R since about 8 years as my one and only way to interact with R. Thank you so much for this!

I noticed this error:

line    7:
E115: Missing quote: '/home/eric/documents/[...]/R

Error detected while processing function ROnJobStdout:
line    7:
E116: Invalid arguments for function RDebugJump

(The path in E115 is much longer.)

while working on a Shiny App that I have put as a R package. Notably, I don't get this error, when simply calling a function containing browser().

The function that I'd like to debug via browser() is ./R/server.R (i.e, relative to the R-file from which I call shiny::runApp())

My configuration in ~/.config/nvim/init.vim: Most interestingly, I had set R_debug = 0 and R_dbg_jmp = 0 when I got this error, but that didn't help it go away. I get this error when using Nvim-R from any branch 'master', 'stable' and 'oldstable'.

Any hint, what I can do to avoid it? It's quite annoying.

call plug#begin('~/.local/share/nvim/plugged')

Plug 'jalvesaq/Nvim-R', {'branch': 'oldstable'}
Plug 'flazz/vim-colorschemes'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-surround'
Plug 'chrisbra/csv.vim' 
" Plug 'preservim/nerdcommenter'
Plug 'mattn/emmet-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive'
Plug 'eigenfoo/stan-vim'
Plug 'vlime/vlime', {'rtp': 'vim/'}
Plug 'kovisoft/paredit'
Plug 'NLKNguyen/papercolor-theme'

call plug#end()

let R_pdfviewer = 'atril'
let R_openhtml = 0
let rout_follow_colorscheme = 0
let R_nvimpager = 'tab'
" let R_hl_term = 1 
" let R_external_term = 0
let R_debug = 0 
let R_dbg_jump = 0
" let r_indent_align_args = 0
" let r_indent_ess_comments = 0
" let r_indent_ess_compatible = 0
" let R_nvim_wd = 1

autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview

filetype plugin indent on

set guifont=Monospace\ 11
let g:molokai_original = 1
set background=dark
colorscheme PaperColor

" vlime config
let g:vlime_window_settings = {
    \ "repl": {
        \ "pos": "botright",
        \ "size": 15,
        \ "vertical": v:false
    \ }
\}

" let g:vlime_cl_impl = "clisp"
jalvesaq commented 2 years ago

I can't replicate the issue because I don't use shiny, but nvimcom is no longer sending the jump command to Nvim-R when R is started while R_debug = 0.

jalvesaq commented 2 years ago

I installed shiny. Could you post here an example of code that triggers the bug, please? I added browser() to the beginning of the server() from the RStudio example, but I didn't get the error that you reported.

jalvesaq commented 2 years ago

I can get a similar error with these two R scripts:

ab'cd.R:

nonsense <- function(x) {
    y <- x + 5
    z <- y - 5
    z
}

testD.R:

source("ab'cd.R")
debug(nonsense)
nonsense(9)
jalvesaq commented 2 years ago

I fixed the bug when the file name of the function being sourced includes single quotes, as in my example above (ab'cd.R).

rcst commented 2 years ago

Thanks @jalvesaq for your swift response!

I put together a reproducible example: https://github.com/rcst/nvimr.shiny.repex. While doing so, I found out, that the problem seems to be rooted in the length of absolute working directory.

Nonetheless, I put together an example that resembles the principle folder structure of what I'm working on.

On Debian, I do

cd ~
mkdir -p test/somelongerfoldername/subdirectory-with-dashes/yet.one.more.subdir.with.dots
cd test/somelongerfoldername/subdirectory-with-dashes/yet.one.more.subdir.with.dots
git clone https://github.com/rcst/nvimr.shiny.repex
cd nvimr.shiny.repex
nvim

I open file app.R and start an R session by \rf and execute shiny::runApp(). This gives me the above error messages.

The call of browser() happens in R/server.R.

Can you reproduce it, too?

jalvesaq commented 2 years ago

It might be fixed now...

rcst commented 2 years ago

It is! Thank you :)