jalvesaq / Nvim-R

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

Nvim-R and Cygwin #163

Closed lucasfariaslf closed 7 years ago

lucasfariaslf commented 7 years ago

I'm trying to use Nvim-R under Cygwin, but when I open the R file and hit \rf, the following error occurs:

* installing *source* package ‘nvimcom’ ...
** libs
gcc -I/usr/lib/R/include -DNDEBUG        -ggdb -O2  -Wimplicit-function-declaration -std=gnu99 -fdebug-prefix-map=/cygdrive/e/cyg_pub/devel/R/R-3.3.2-1.x86_64/build=/usr/src/debug/R-3.3.2-1 -fdebug-prefix-map=/cygdrive/e/cyg_pub/devel/R/R-3.3.2-1.x86_64/src/R-3.3.2=/usr/src/debug/R-3.3.2-1  -c nvimcom.c -o nvimcom.o
gcc -shared -L/usr/lib/R/lib -o nvimcom.dll nvimcom.o -L/usr/lib/R/lib -lR -lintl -lpcre -llzma -lbz2 -lz -ltirpc -lrt -ldl -lm -liconv -licuuc -licui18n
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ltirpc
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licuuc
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licui18n
collect2: error: ld returned 1 exit status
make: *** [/usr/lib/R/share/make/shlib.mk:6: nvimcom.dll] Error 1
ERROR: compilation failed for package ‘nvimcom’
* removing ‘/usr/lib/R/site-library/nvimcom’

I've tried it with both Rtools 3.3 and 3.4, since I remember reading there was a warning regarding its version, but the same error occurred.

Less than a year ago @jalvesaq warned he wasn't sure it would be possible to use Nvim-R under Cygwin, I just want to know if the nature of my error I'm getting sheds some light on how [if it's possible] to make it work.

jalvesaq commented 7 years ago

Perhaps there is a mismatch between the R that Nvim-R is running and the gcc that is being called to compile nvimcom. You can check what R Nvim-R is trying to run:

:echo rplugin_R

And in the Cygwin terminal, you could try to use this R to build the nvimcom package and manually install it:

cd ~/path/to/Nvim-R/R
R CMD build nvimcom
R CMD INSTALL nvimcom

The path to R directory depends on how you have installed Nvim-R. It might be:

~/.vim/plugged/Nvim-R/R # vim-plug plugin
~/.vim/R # Vimball
~/.vim/pack/foo/start/Nvim-R/R # Vim package, where "foo" is the name that you have chosen.

If you are running an R that was compiled for Cygwin, I guess you should not use Rtools. You should use Cygwin's gcc and make.

If you are running R for Windows, downloaded from R website, then you should use gcc that comes with Rtools.

lucasfariaslf commented 7 years ago

Apparently Nvim-R is trying to use the R installed in Windows (although I can't check it; when I try :echo rplugin_R in VIM nothing happens, just the letter R appears on the command line).

Since I used vim-plug, I went to ~/.vim/plugged/Nvim-R/R and ran the build and install commands.

R CMD build nvimcom output:

$ R CMD build nvimcom
* checking for file ‘nvimcom/DESCRIPTION’ ... OK
* preparing ‘nvimcom’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building ‘nvimcom_0.9-26.tar.gz’
Warning: invalid uid value replaced by that for user 'nobody'
Warning: invalid gid value replaced by that for user 'nobody'

But then R CMD INSTALL nvimcom resulted in the same error:

$ R CMD INSTALL nvimcom
* installing to library ‘/usr/lib/R/site-library’
* installing *source* package ‘nvimcom’ ...
** libs
gcc -shared -L/usr/lib/R/lib -o nvimcom.dll nvimcom.o -L/usr/lib/R/lib -lR -lintl -lpcre -llzma -lbz2 -lz -ltirpc -lrt -ldl -lm -liconv -licuuc -licui18n
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ltirpc
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licuuc
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licui18n
collect2: error: ld returned 1 exit status
make: *** [/usr/lib/R/share/make/shlib.mk:6: nvimcom.dll] Error 1
ERROR: compilation failed for package ‘nvimcom’
* removing ‘/usr/lib/R/site-library/nvimcom’

Thanks for helping!

jalvesaq commented 7 years ago

These errors indicate that there are missing development headers:

/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ltirpc
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licuuc
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licui18n

You should install something like the development packages for libtirpc, libicuuc and libicui18n. I have no idea of what these libraries are, but you could try to discover how to install their development packages on Cygwin.

lucasfariaslf commented 7 years ago

Agreed. Doesn't seem to be an issue with Nvim-R anyway. Think we can close this issue then.

Thank you once again, Jackson!

lucasfariaslf commented 7 years ago

Sorry, Jackson. Not sure if I should close it, though, as of now I'm installing these libraries in Cygwin and if it gets the issue fixed might be helpful for other users to know it's effective.

jalvesaq commented 7 years ago

It's a feature request. So, we can let the issue open until it is solved. I don't use Cygwin, but either you or someone else might fix the issue.

lucasfariaslf commented 7 years ago

Well, after installing the missing libraries (with the help of this question on StackOverflow, to find in which library licuuc was in) I could finally install nvimcom.

But unfortunately, when I hit \rf in an example R file it says it successfully updated nvimcom, but then I get "Job" exited with status 1, and after some seconds it changes to R did not load nvimcom yet. When I try \d I get error connecting to /tmp/tmux-1157244/NvimR (No such file or directory)

psc.: I got the libraries directly from cygwin's setup.exe, in case another user wonders.

jalvesaq commented 7 years ago

Just some ideas:

lucasfariaslf commented 7 years ago

/usr/local/bin:/usr/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files(x86)/QuickTime/QTSystem:/cygdrive/c/texlive/2016/bin/win32:/usr/lib/lapack

Still no clue about R...

jalvesaq commented 7 years ago

If it was trying to use R for Windows, the $PATH would contain /cygdrive/c/Program Files/R/R-3.2.2/bin/x64. It's not the case, so it might be using R from either /usr/bin or /usr/local/bin.

Another idea to know what R Vim is trying to run: :!which R

lucasfariaslf commented 7 years ago

You were right, :!which R yields /usr/bin/R.

But still, I checked library(nvimcom) and it's already installed in it, so I'm not sure what else to do. It seems the problem now revolves around this R did not load nvimcom yet and \d yielding /tmp/tmux-1157244/NvimR (No such file or directory).

jalvesaq commented 7 years ago

The problem might be related with Tmux, and I would have to install Cygwin to try to fix the issue. I already support many setups that I don't use (Vim on Linux and Gvim on Windows), and I cannot afford to support another. So, unfortunately, we have to wait until someone else fixes the issue.

jalvesaq commented 7 years ago

@lucasfariaslf Please, see https://github.com/jalvesaq/Nvim-R/issues/127 Perhaps @polde-live can help you.

kotalbert commented 7 years ago

@lucasfariaslf What vim version do you have? Can you paste whay :version yields? Did you have required libraries libtirpc, libicuuc and libicui18n installed? It took me a while to get it working under Cygwin64.

lucasfariaslf commented 7 years ago

@jalvesaq Thank you again.

@polde-live Apparently I have version 8, :version output:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 15 2017 20:44:18) Included patches: 1-329 Modified by <cygwin@cygwin.com> Compiled by <cygwin@cygwin.com> Huge version without GUI. Features included (+) or not (-): +acl +cmdline_compl +digraphs +folding +langmap -mouseshape -mzscheme +python3/dyn +syntax -toolbar +writebackup +arabic +cmdline_hist -dnd -footer +libcall +mouse_dec +netbeans_intg +quickfix +tag_binary +user_commands -X11 +autocmd +cmdline_info -ebcdic +fork() +linebreak -mouse_gpm +num64 +reltime +tag_old_static +vertsplit -xfontset -balloon_eval +comments +emacs_tags +gettext +lispindent -mouse_jsbterm +packages +rightleft -tag_any_white +virtualedit -xim -browse +conceal +eval -hangul_input +listcmds +mouse_netterm +path_extra +ruby/dyn -tcl +visual -xpm ++builtin_terms +cryptv +ex_extra +iconv +localmap +mouse_sgr +perl/dyn +scrollbind +termguicolors +visualextra -xsmp +byte_offset +cscope +extra_search +insert_expand +lua/dyn -mouse_sysmouse +persistent_undo +signs +terminfo +viminfo -xterm_clipboard +channel +cursorbind +farsi +job +menu +mouse_urxvt +postscript +smartindent +termresponse +vreplace -xterm_save +cindent +cursorshape +file_in_path +jumplist +mksession +mouse_xterm +printer +startuptime +textobjects +wildignore -clientserver +dialog_con +find_in_path +keymap +modify_fname +multi_byte +profile +statusline +timers +wildmenu +clipboard +diff +float +lambda +mouse +multi_lang +python/dyn -sun_workshop +title +windows system vimrc file: "/etc/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/etc" f-b for $VIMRUNTIME: "/usr/share/vim/vim80" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/vim/vim-8.0.0329-1.x86_64/build=/usr/src/debug/vim-8.0.032 9-1 -fdebug-prefix-map=/usr/src/ports/vim/vim-8.0.0329-1.x86_64/src/vim-8.0.0329=/usr/src/debug/vim-8.0.0329-1 -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -L. -fstack-protector -fstack-protector-strong -L/usr/local/lib -Wl,--as-needed -o vim.exe -lm -lncursesw -liconv -lacl -lattr -lintl -Wl,--enable-auto-import -Wl,- -export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/lib/perl5/5.22/x86_64-cygwin-threads/CORE -lperl -lpthread -ldl -lcrypt

I do have all these libraries installed, the problem began with them.

Thank you a lot for helping!

lucasfariaslf commented 7 years ago

What is really weird to me is that it's looking for a folder that was supposed to be created:

error connecting to /tmp/tmux-1157244/NvimR (No such file or directory)

tmux-1157244 is empty, save the "default" system file in it. I wonder if it should be looking for the Nvim-R-lucasfariaslf that's inside tmp.

jalvesaq commented 7 years ago

I guess that you have to put let R_tmux_split = 1 in your vimrc and, then, start tmux before vim. Otherwise, Nvim-R will try to open an external terminal, and this might not be possible in Cygwin.

lucasfariaslf commented 7 years ago

@jalvesaq that was it! It finally worked. I had already tried having tmux opened before starting vim without success, let R_tmux_split = 1 was the missing line.

By the way, what it does exactly?

Thanks once again!

jalvesaq commented 7 years ago

By default, Nvim-R tries to start a new terminal emulator running Tmux (and Tmux running R). When the value of R_tmux_split is 1, Vim runs tmux split-window (which splits the current Tmux window) and, then, sends the R command to the other tmux pane.

Since you got Nvim-R working inside tmux, you could also try to install the colorout package from https://github.com/jalvesaq/colorout (but I don't know if it compiles on Cygwin).

lucasfariaslf commented 7 years ago

Got it, @jalvesaq. Thank you for explaining.

By the way, colorout installed and working like a charm! Helps a lot! Thank you once again! Feel free to close the issue!

lucasfariaslf commented 7 years ago

One quick question, though: Rstudio has this feature in which Ctrl-Enter runs the whole command, going through commas and if statements, for example. Is there any way I could emulate this behavior using Nvim-R? I thought \bb or \cc would do it, but when I the first vim says The file has no mark!, while \cc just calls the cc command from Vim, which deletes the line and enters insert mode.

jalvesaq commented 7 years ago

No, Nvim-R does not do that. You can open an issue requesting this feature, and I may implement it in the future. In the meanwhile, you may select the code and send it with \ss or mark a block of code with normal mode commands like ma and mb (to mark two lines with the marks a and b respectively). The plugin signature will show the marks to you. You can also send a sequence of lines (until the next blank line) with \pp.