Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something odd with RCDT, callr and nix #329

Closed
HVinther opened this issue Sep 24, 2024 · 9 comments
Closed

Something odd with RCDT, callr and nix #329

HVinther opened this issue Sep 24, 2024 · 9 comments

Comments

@HVinther
Copy link

HVinther commented Sep 24, 2024

So I've encountered a problem and not sure whether this is a problem of rix, a packing issue of nix or a problem with the packages themselves.

I've got the following file for generating the nix-enviroment. I've tried with r_ver as "4.4.0" and "bleeding edge"

rix::rix(
  r_ver = "bleeding_edge",
  r_pkgs = c("targets","RCDT"),
  ide = "code",
  overwrite = TRUE,
  print = TRUE
)

And the following _targets.R file

library(targets)

tar_option_set(
  packages = c("RCDT")
)

list(
  tar_target(name = "test",command = version)
)

When running targets::tar_make() inside the nix shell I get the following error message

Error in `get_result(output = out, options)`:
! callr subprocess failed: could not start R, exited with non-zero status, has crashed or was killed
ℹ See `$stderr` for standard error.

However, when running targets::tar_make(callr_function = NULL) the pipeline executes as expected.
When I call

callr::r(\(x){version},package = "RCDT")

It does yield the above error message along with a warning, which also appears if I call library("RCDT") from within an ide (here positron). Calling library("RCDT") from within an ide I do however not get an error.

Warning message:
input string '  author = {Stéphane Dray and Anne-Béatrice Dufour and Jean Thioulouse and Thibaut Jombart and Sandrine Pavoine and Jean R. Lobry and Sébastien Ollier and Aurélie Siberchicot and Daniel Chessel},' cannot be translated from 'ANSI_X3.4-1968' to UTF-8, but is valid UTF-8 

When calling library("RCDT") from a terminal R-session I get prompted with

Selection:

Entering a number causes a segmentation fault. But entering a string just gives the prompt again.

Now, none of these problems arise in a rocker/r2u docker container. Calling library("RCDT") just loads the package with out error or warning in both an IDE and terminal.

I see that in the default.nix file created by rix, there are som LANG arguments in the pkgs.mkshell function, and since the warning mentions something about ANSI and UTF-8, I was wandering whether there might be an issue there.

I'm still quite new to nix, so I'm not quite sure yet how to determine if this is a problem with the nix packaging of RCDT or something else. Please redirect me, if you think the issue is better raised elsewhere.

@HVinther
Copy link
Author

Ok, I just created a temporary enviroment with:

nix-shell -p R rPackages.callr rPackages.RCDT

Where the issue persisted. I'll report this on NixOS/nixpkgs instead.

@b-rodrigues
Copy link
Contributor

Thanks, we also contribute to the R packages ecosystem on nixpkgs, so feel free to reference this issue in the one you’re going to open!

@HVinther
Copy link
Author

Perhaps a wrapping using nixGL could be added to rix to solve problems with openGL dependency like this?
NixOS/nixpkgs#344213 (comment)

@b-rodrigues
Copy link
Contributor

Yep, that’s indeed something that we should at least document. We’ll have to try this on windows (WSL2) and macOS as well if we want to go towards an automated solution.

@HVinther
Copy link
Author

HVinther commented Sep 27, 2024

Now, both issues are closed, but I would just like mentioned, that I was able to build the default.nix provided by rix with seemingly opengl support with the following command. I think I'll just save this as a bash script to use instead of nix-shell.

$(nix-build https://github.com/nix-community/nixGL/archive/master.tar.gz -A nixGLIntel)/bin/nixGLIntel nix-shell

@philipp-baumann
Copy link
Collaborator

philipp-baumann commented Sep 27, 2024

Yep, that’s indeed something that we should at least document. We’ll have to try this on windows (WSL2) and macOS as well if we want to go towards an automated solution.

i really don't know if its just an Intel problem.

> library(targets)
> tar_make()
> dispatched target test
o completed target test [0.13 seconds]
> ended pipeline [0.163 seconds]
> tar_load(test)
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin23.6.0
Running under: macOS Sonoma 14.2.1

Matrix products: default
BLAS:   /nix/store/p0piq9717s687n34sarwn07wzbimmvig-blas-3/lib/libblas.dylib 
LAPACK: /nix/store/liz9lfphmcygp4v1n33mav5gspi8cnfl-openblas-0.3.28/lib/libopenblasp-r0.3.28.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Zurich
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] targets_1.7.1

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5       cli_3.6.3         knitr_1.48        rlang_1.1.4      
 [5] xfun_0.47         processx_3.8.4    data.table_1.16.0 glue_1.7.0       
 [9] backports_1.5.0   ps_1.8.0          fansi_1.0.6       tibble_3.2.1     
[13] base64url_1.4     yaml_2.3.10       lifecycle_1.0.4   compiler_4.4.1   
[17] codetools_0.2-20  igraph_2.0.3      pkgconfig_2.0.3   R6_2.5.1         
[21] tidyselect_1.2.1  utf8_1.2.4        pillar_1.9.0      callr_3.7.6      
[25] magrittr_2.0.3    tools_4.4.1       withr_3.0.1       secretbase_1.0.2 
> .libPaths()
 [1] "/nix/store/1ca5vr25gx4gch5vjjn2qhgzw1gqmikx-r-RCDT-1.3.0/library"                         
 [2] "/nix/store/x1vxxvcbhizw506lbaf9rv3r34v83wrm-r-BH-1.84.0-0/library"                        
 [3] "/nix/store/m7yaibqx5ikqw5bmai2f61zawwggp3r5-r-Polychrome-1.5.1/library"                   
 [4] "/nix/store/4frfbifa33d619ar9n32m3nyfdpn9mif-r-colorspace-2.1-1/library"                   
 [5] "/nix/store/6x0sssh8cqhvxblgavzg6aaf3b9zz72q-r-scatterplot3d-0.3-44/library"               
 [6] "/nix/store/ix1w8f10h1mpc9nhamrj2fdni4gks4ll-r-Rcpp-1.0.13/library"                        
 [7] "/nix/store/j52zajacaryyxw7m28m71hgphjjp3cvr-r-RcppArmadillo-14.0.2-1/library"             
 [8] "/nix/store/glvdxma8vjcmhqm952634an2yqqiqrpc-r-Rvcg-0.24/library"                          
 [9] "/nix/store/38cf0sck27pfbr7sdf9sv05b1p4hm9h1-r-RcppEigen-0.3.4.0.2/library"                
[10] "/nix/store/xkx29pimsd1aw57wp4m0idjm8gl3qjn2-r-colorsGen-1.0.0/library"                    
[11] "/nix/store/5vz6rbs9qh1lxg9ka7cl20nsil6mgxgc-r-gplots-3.1.3.1/library"                     
[12] "/nix/store/wc5nn6wia226nyp82r11i9dzaxm6jik8-r-KernSmooth-2.23-24/library"                 
[13] "/nix/store/i04l75sbwknsydahyvfblfhsyhy6hvhr-r-caTools-1.18.3/library"                     
[14] "/nix/store/sj7zfwqbwiny3w0ssrvdkhvwk9qsyakv-r-bitops-1.0-8/library"                       
[15] "/nix/store/4lwzpj997376pn18mmg6lgklzjfy81jx-r-gtools-3.9.5/library"                       
[16] "/nix/store/9m113x489clp7ig8pbaxv35f7yv0g2bj-r-rgl-1.3.1/library"                          
[17] "/nix/store/wzq9mscja7ifz8vij2yn62a574rx5b7p-r-R6-2.5.1/library"                           
[18] "/nix/store/b9dpz9b3rsk3dsvybz279ly1sjcsbh3g-r-base64enc-0.1-3/library"                    
[19] "/nix/store/cr9m1zh20z1kly0xvap83xlwmcr0jvri-r-htmltools-0.5.8.1/library"                  
[20] "/nix/store/f68vpj103qy46slrzx8ml5h1zvkp0g2g-r-digest-0.6.37/library"                      
[21] "/nix/store/1j2iw6yq29wamb4b3h3jy2zpkfxmwyx0-r-fastmap-1.2.0/library"                      
[22] "/nix/store/l3gpy7b266lk87414jgb2qlxb3cf5cji-r-rlang-1.1.4/library"                        
[23] "/nix/store/ai24qsqn0kfw5gxqlsskc51qgg1vzi42-r-htmlwidgets-1.6.4/library"                  
[24] "/nix/store/fvalarrqlbb4yr85pxijy6ld88d6w3gm-r-jsonlite-1.8.9/library"                     
[25] "/nix/store/adf51x0hw0mbpzd90zsar24scckppx5b-r-knitr-1.48/library"                         
[26] "/nix/store/64a8piz3ri97czzl1wwbzyzp2qb08dm2-r-evaluate-1.0.0/library"                     
[27] "/nix/store/j1h0448vmgf1lk6ammw4cv15gxf3zp2v-r-highr-0.11/library"                         
[28] "/nix/store/mf1i9ca06c8azjxjj400mbjh1iyk3p67-r-xfun-0.47/library"                          
[29] "/nix/store/p0gngi6wac6j36aclpz0bkwri9kz1yjy-r-yaml-2.3.10/library"                        
[30] "/nix/store/540l8xx0nn5d1jzxii3lblfwrlidd7iw-r-rmarkdown-2.28/library"                     
[31] "/nix/store/dldq4i1adn88dg4pzg4gymig0lk3d65d-r-bslib-0.8.0/library"                        
[32] "/nix/store/5h11g4ndk22zmds41wv6lp7zcndsarp6-r-cachem-1.1.0/library"                       
[33] "/nix/store/5b1j6sm2j4n5fw24s75p3lc2dzf77j79-r-jquerylib-0.1.4/library"                    
[34] "/nix/store/by7pxkr9ziz1i97ib9iq9g7r4vz60cxq-r-lifecycle-1.0.4/library"                    
[35] "/nix/store/2r1qnz2k8gh91kqpyz4zrzyk6hhbdwhz-r-cli-3.6.3/library"                          
[36] "/nix/store/n0xnlaqxmyvlcacsc2yghmk0rjpbsrsz-r-glue-1.7.0/library"                         
[37] "/nix/store/bkhcjlwimhsq1v87lrxmi0myhfpw8044-r-memoise-2.0.1/library"                      
[38] "/nix/store/j6rl9gfqj86ya7xj1mzlmqyic3gfzam5-r-mime-0.12/library"                          
[39] "/nix/store/8s5wfcflmpaxh8cwmf65n3pirlg8v86d-r-sass-0.4.9/library"                         
[40] "/nix/store/91hayx7v9qissjgnv3ckzp3a3z8ivnzy-r-fs-1.6.4/library"                           
[41] "/nix/store/9v3c0d0mfyw08f4m8nkqn3qfhhyzlxqv-r-rappdirs-0.3.3/library"                     
[42] "/nix/store/kl2i3nd4wb89xmvx2f88ymb3ka41g8l2-r-fontawesome-0.5.2/library"                  
[43] "/nix/store/b596jrraq0ppsps47kwl0h0f89v99h1i-r-tinytex-0.53/library"                       
[44] "/nix/store/9bja5awlgvha85ff114yvnirkm43q68v-r-magrittr-2.0.3/library"                     
[45] "/nix/store/laxnsgi2vmkpnxgrjlhnqwmd8prp7id0-r-languageserver-0.3.16/library"              
[46] "/nix/store/16yh0xqvkyjd8cjd9yxf606a9bj3jyfj-r-callr-3.7.6/library"                        
[47] "/nix/store/haxfkrn5ll0rkh4wmcspmxyfqkvzda06-r-processx-3.8.4/library"                     
[48] "/nix/store/5ssmvk600ls85fhac5vykfsrblknhyxy-r-ps-1.8.0/library"                           
[49] "/nix/store/8rx9y42gj6igbd0nz4qhbr6kj5j22s1c-r-collections-0.3.7/library"                  
[50] "/nix/store/mxc89m3byksbmgirbcrz12y85y0k1b22-r-lintr-3.1.2/library"                        
[51] "/nix/store/831zdnhqqdfazqqbgl4mvk7lryb3jym9-r-backports-1.5.0/library"                    
[52] "/nix/store/1hq4iys5gfa8wgsv1nbapbp0wsljf47j-r-codetools-0.2-20/library"                   
[53] "/nix/store/9z8l45h2p65j84vbzqcxxcpp8r89l60a-r-cyclocomp-1.1.1/library"                    
[54] "/nix/store/6a5856gaaqgbx77qp7gcj7sh1v3c3vgx-r-crayon-1.5.3/library"                       
[55] "/nix/store/msiwzrpvpfzc51c5b0wgklh3r0pvbcaf-r-desc-1.4.3/library"                         
[56] "/nix/store/byfk2qs231gv00916fzaqk1j7iy2b3wy-r-remotes-2.5.0/library"                      
[57] "/nix/store/grpd38ms14jbc4cinwxcfw7fggn4jxib-r-withr-3.0.1/library"                        
[58] "/nix/store/rxg8sq9ggd6nbgfl806nhvpj9zmcagyc-r-rex-1.2.1/library"                          
[59] "/nix/store/v4pjdah6834m3kgpa18zlimsjl7g84jc-r-lazyeval-0.2.2/library"                     
[60] "/nix/store/z4x0isw6xs17la7ylscphwccxs2qb3wy-r-xml2-1.3.6/library"                         
[61] "/nix/store/67912y9ijyzp83n1fyv3i00l8ic5sq4y-r-xmlparsedata-1.0.5/library"                 
[62] "/nix/store/1nya00lhwdv5ym9nkrq6n1m7d1dsmiii-r-roxygen2-7.3.2/library"                     
[63] "/nix/store/dg8fyqwmx61kxrs3zmllna4afwsfmya3-r-brew-1.0-10/library"                        
[64] "/nix/store/j1jib2jzc34a8zhx31hmswgiajwm70s7-r-commonmark-1.9.1/library"                   
[65] "/nix/store/4n7d2m12najbrz28mnx6dwghax23fzxm-r-cpp11-0.5.0/library"                        
[66] "/nix/store/m0ycxx09jyqba7jyhkcndbxp68ijahhy-r-pkgload-1.4.0/library"                      
[67] "/nix/store/rib5vaagx8jhzqy4j1pkjar99pdl1ilz-r-pkgbuild-1.4.4/library"                     
[68] "/nix/store/smv6flkhmji0a54l5j8s4353z4knk16x-r-rprojroot-2.0.4/library"                    
[69] "/nix/store/zal3y264fzcj4hb05bc03nb0d854k4z2-r-purrr-1.0.2/library"                        
[70] "/nix/store/ysmdhjpbzslba5q6wz41a06p1a7xinki-r-vctrs-0.6.5/library"                        
[71] "/nix/store/qv69qnqsgkhkjw04gc8jkbmk9a3rwkj6-r-stringi-1.8.4/library"                      
[72] "/nix/store/887nz9yjcbr7brlq7hjak9fx7rwmk7gq-r-stringr-1.5.1/library"                      
[73] "/nix/store/gqimvb43fhkvcx9z72r04k4gympq30r5-r-styler-1.10.3/library"                      
[74] "/nix/store/ha37nzbj0s0708lxiq92w968qbqv2rzl-r-R.cache-0.16.0/library"                     
[75] "/nix/store/5skyfshvs5mrkkszss05dvxj62xs3w6v-r-R.methodsS3-1.8.2/library"                  
[76] "/nix/store/q5hvv3cf0lpvprcs55mz0d6cyhiq6cmr-r-R.oo-1.26.0/library"                        
[77] "/nix/store/fkr7mgkzf5afzxacdxyrx53z3zd950ad-r-R.utils-2.12.3/library"                     
[78] "/nix/store/wg22qfv19l8n2lc45nzsxx1sdpwnniz9-r-targets-1.7.1/library"                      
[79] "/nix/store/jnp5a7v8jmlhbl3whmmvx06y4h75yf44-r-base64url-1.4/library"                      
[80] "/nix/store/8q2akn48vsmls433amkqjq6gyig0rg82-r-data.table-1.16.0/library"                  
[81] "/nix/store/i6pv0870jgllcd6qj1a5mymmbj9bh3bv-r-igraph-2.0.3/library"                       
[82] "/nix/store/zx9lq1pvxvga5673nqvp97wa0l4y6f58-r-Matrix-1.7-0/library"                       
[83] "/nix/store/hm6apii269lzfcrxdwsmkxk8vcsrgc85-r-lattice-0.22-6/library"                     
[84] "/nix/store/rxa53s63z3arxasn1rghz93zy4y0nsgm-r-pkgconfig-2.0.3/library"                    
[85] "/nix/store/320zjp9c29w3l9nv1y9djxg1d3xy8gfr-r-secretbase-1.0.2/library"                   
[86] "/nix/store/qdwxg4wvs3662dsak12jz5x2s23z5axn-r-tibble-3.2.1/library"                       
[87] "/nix/store/pxbjncdhvjjvazd9ml5j8pn48032j84j-r-fansi-1.0.6/library"                        
[88] "/nix/store/xk9sfb5a670amnhf6kshwpri3a3k0sxh-r-pillar-1.9.0/library"                       
[89] "/nix/store/z3lhiplpp0lz7907jyx661a7zb2fwlwd-r-utf8-1.2.4/library"                         
[90] "/nix/store/l26q6ipv1bvbfjp79kzdj22snz0ddfaf-r-tidyselect-1.2.1/library"                   
[91] "/nix/store/s4ansjcc1dd63yn040ssw8qjrawl28ai-nix-2.18.8/Library"                           
[92] "/nix/store/kcn9w36a573nhkbl5ci7aa2vdk2q5k16-apple-framework-CoreFoundation-11.0.0/Library"
[93] "/nix/store/l5hm8k0r79bk1j2556wp1l4cmmrvza7v-R-4.4.1/lib/R/library"    

Also, positron is like @jbedo mentioned doing weird stuff with the locale and also not correctly inheriting envvars from standard shell (probably because of a startup mechanism) rstudio/rstudio#12747. I have seen a lot of stuff like this, PATH is modified. Stuff set in local .Rprofile is changed by other hacks in RStudio, and i would not be surprised if positron does unintended stuff behind the scenes favorizing posit packages and stuff. In that sense i am hesitating to implement such workarounds in {rix}.

@HVinther
Copy link
Author

Both my cpu and gpu are from amd, so I don't think it is an intel problem. There might however be some issue with positron as well as you mention. If build the shell with the nixGL wrapper my positron console crashed when I load RCDT, even though an R session from the same shell loads and runs the library without problem. I have however installed positron in a weird way, as I have converted the .deb package to an .rpm using alien. I have not however found other R packages that causes a similar issue.

@HVinther
Copy link
Author

Both my cpu and gpu are from amd, so I don't think it is an intel problem. There might however be some issue with positron as well as you mention. If build the shell with the nixGL wrapper my positron console crashed when I load RCDT, even though an R session from the same shell loads and runs the library without problem. I have however installed positron in a weird way, as I have converted the .deb package to an .rpm using alien. I have not however found other R packages that causes a similar issue.

The crashing might be a problem with the ark kernel. I've tried loading loading RCDT in an ark jupyter console and zed both from the nixGL shell. The jupyter console becomes unresponsive when loading RCDT, while zed displays a (jupyter) kernel error: "Kernel error: kernel process exited with status: ExitStatus(unix_wait_status((139))". The console in positron reloads with the following error: "R 4.4.1 exited unexpectedly: killed with signal 11 (SIGSEGV)". I have not tried other R jupyter kernels, but maybe this should reported as a bug in ark?

@b-rodrigues
Copy link
Contributor

Interesting, maybe try to see if the error persists with another kernel and if not, then I guess this could interest the ark developers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants