jalvesaq / Nvim-R

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

Nvimcom fails to install on FreeBSD #810

Closed Arethusag closed 7 months ago

Arethusag commented 7 months ago

Hi All,

Asking any maintainer of this plugin for some guidance on the build steps of the nvimcom server. I have a minimal .vimrc and here is the output of :RDebugInfo after nvimcom fails to compile.

Looks like the issue is some of the structs could be unsupported by the FreeBSD version of clang compiler.

Why build nvimcom
Nvimcom not installed
before_nrs.R stdout
* checking for file ‘/home/mmarcoux/.vim/pack/plugins/start/Nvim-R-0.9.20/R/nvimcom/DESCRIPTION’ ... OK
* preparing ‘nvimcom’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘nvimcom_0.9-163.tar.gz’
cc -I"/usr/local/lib/R/include" -DNDEBUG   -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include    -fpic  -O2 -pipe  -DLIBICONV_PLUG -fstack-protector-strong
-isystem /usr/local/include -fno-strict-aliasing   -c nvimcom.c -o nvimcom.o
Time
  before_nrs.R: 1.184001
  common_global.vim: 0.010427
  GlobalRInit: 0.008865
before_nrs.R stderr

.build_packages() exit status 0
* installing to library ‘/home/mmarcoux/R/amd64-portbld-freebsd14.0-library/4.3’
* installing *source* package ‘nvimcom’ ...
** using staged installation
** libs
using C compiler: ‘FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)’
nvimcom.c:1298:28: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in servaddr;
                           ^
nvimcom.c:1298:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in servaddr;
               ^
1 error generated.
gmake: *** [/usr/local/lib/R/etc/Makeconf:191: nvimcom.o] Error 1
ERROR: compilation failed for package ‘nvimcom’
* removing ‘/home/mmarcoux/R/amd64-portbld-freebsd14.0-library/4.3/nvimcom’
Error in do_exit(status = status) : .install_packages() exit status 1
Error in do_exit(status = status) : .install_packages() exit status 1

I think once I know more about what the plugin is expecting here, and if this is just an idiosyncracy between FreeBSD and Linux, then I will know how to proceed. I will report back if I figure out anything else.

Thanks for you time!

jalvesaq commented 7 months ago

The nvimcom package includes a TCP server application run by Vim, not by R. The nvimcom C library connects with the TCP server and, then, the connection between Vim and R is established.

Possibly, a C header is missing or is in the wrong order. You could compare lines 10-30 of nvimcom.c with lines 7-11 of https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-first-client and try changing the order of header inclusion or including missing headers.

Arethusag commented 7 months ago

Hi @jalvesaq

Thanks for the suggestions. I included some missing header files #include <netinet/in.h> and tried to get the correct order, and this helped with the initial error I was having. However the build now fails with this error.

Sorry I am not a C-programmer and the logic for the server is complex, I may try getting a minimum producable example. Any suggestion is welcome.

jalvesaq commented 7 months ago

The error is the same, but now in the server:

nvimrserver.c:303:24: error: variable has incomplete type 'struct sockaddr_in'

You may fix it in the same way, including headers and changing their order in R/nvimcom/src/apps/nvimrserver.c.

Arethusag commented 7 months ago

Thanks @jalvesaq

nvimcom now builds after including the additional header file. I tested starting R and it all seems to work nicely. Did you want a PR to add FreeBSD support?

jalvesaq commented 7 months ago

Yes, please.