Error in compileCode in brms ubuntu 20.04

Dear all,

I’ve been having such a lovely time in the land of Linux, until a few weeks ago my compiler stopped worked unexpectedly. I am on Ubuntu 20.04, all packages up to date (sessionInfo at bottom of this message). Please see test code and error messages through brms below. Please also see the very long error output for example(stan_model, package = "rstan", run.dontrun = TRUE) attached rstan_compile_error_ubuntu_20.04_31.03.21.txt (34.4 KB).

I’ve seen recent problems in Windows (Error in compileCode(f, code, language = language, verbose = verbose) & Error in sink(type = "output") : invalid connection) and a few years ago in Ubuntu (Compiling error when running model in Ubuntu 18.04. Any ideas?) but the solutions there do not work for me.

Abundant thanks in advance for your help, I look forward to getting back to the Bayes!

#brms test
library(brms)
test <- data.frame(x = round(rnorm(20, 20, 5),0),
                y = round(rnorm(20, 2, 0.2),2))

brm(y ~ x, data = test,
    iter = 500, warmup = 250, chains = 1)

Compiling Stan program...
make cmd is
  make -f '/usr/lib/R/etc/Makeconf' -f '/usr/share/R/share/make/shlib.mk' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file35532f8a7d7c.so' OBJECTS='file35532f8a7d7c.o'

make would use
if test  "zfile35532f8a7d7c.o" != "z"; then \
  echo g++ -std=gnu++14 -shared -L"/usr/lib/R/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -o file35532f8a7d7c.so file35532f8a7d7c.o  '/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/rstan/lib//libStanServices.a' -L'/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/StanHeaders/lib/' -lStanHeaders -L'/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/RcppParallel/lib/' -ltbb  -L"/usr/lib/R/lib" -lR; \
  g++ -std=gnu++14 -shared -L"/usr/lib/R/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -o file35532f8a7d7c.so file35532f8a7d7c.o  '/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/rstan/lib//libStanServices.a' -L'/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/StanHeaders/lib/' -lStanHeaders -L'/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/RcppParallel/lib/' -ltbb  -L"/usr/lib/R/lib" -lR; \
fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
  /home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/StanHeaders/include/src/stan/model/model_base_crtp.hpp:149:20:   required from here/home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(2) double’} [-Wignored-attributes]/usr/bin/ld: /home/gzf2/R/x86_64-pc-linux-gnu-library/4.0/rstan/lib//libStanServices.a(stan_fit.o): relocation R_X86_64_PC32 against undefined hidden symbol `_ZTCN5boost10wrapexceptINS_4math14rounding_errorEEE0_NS_16exception_detail10clone_implINS4_19error_info_injectorIS2_EEEE' can not be used when making a shared object/usr/bin/ld: final link failed: bad valuecollect2: error: ld returned 1 exit statusmake: *** [/usr/share/R/share/make/shlib.mk:10: file35532f8a7d7c.so] Error 1
Error in sink(type = "output") : invalid connection

sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8
[6] LC_MESSAGES=en_CA.UTF-8 LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] brms_2.15.0 Rcpp_1.0.6

loaded via a namespace (and not attached):
[1] minqa_1.2.4 colorspace_2.0-0 ellipsis_0.3.1 class_7.3-18 modeltools_0.2-23 ggridges_0.5.2
[7] rsconnect_0.8.16 mclust_5.4.7 estimability_1.3 markdown_1.1 base64enc_0.1-3 rstudioapi_0.13
[13] rstan_2.21.2 flexmix_2.3-17 DT_0.16 fansi_0.4.1 mvtnorm_1.1-1 bridgesampling_1.0-0
[19] codetools_0.2-18 splines_4.0.4 robustbase_0.93-6 shinythemes_1.1.2 bayesplot_1.7.2 projpred_2.0.2
[25] jsonlite_1.7.2 nloptr_1.2.2.2 cluster_2.1.1 kernlab_0.9-29 shiny_1.5.0 compiler_4.0.4
[31] emmeans_1.5.3 backports_1.2.1 assertthat_0.2.1 Matrix_1.3-2 fastmap_1.0.1 cli_2.2.0
[37] later_1.1.0.1 htmltools_0.5.1.1 prettyunits_1.1.1 tools_4.0.4 igraph_1.2.6 coda_0.19-4
[43] gtable_0.3.0 glue_1.4.2 reshape2_1.4.4 dplyr_1.0.2 V8_3.4.0 vctrs_0.3.5
[49] nlme_3.1-152 fpc_2.2-9 crosstalk_1.1.0.1 stringr_1.4.0 ps_1.5.0 lme4_1.1-26
[55] mime_0.9 miniUI_0.1.1.1 lifecycle_0.2.0 gtools_3.8.2 statmod_1.4.35 DEoptimR_1.0-8
[61] MASS_7.3-53.1 zoo_1.8-8 scales_1.1.1 colourpicker_1.1.0 promises_1.1.1 Brobdingnag_1.2-6
[67] parallel_4.0.4 inline_0.3.17 shinystan_2.5.0 gamm4_0.2-6 curl_4.3 gridExtra_2.3
[73] ggplot2_3.3.2 loo_2.4.1 StanHeaders_2.21.0-7 stringi_1.5.3 dygraphs_1.1.1.6 boot_1.3-27
[79] pkgbuild_1.2.0 rlang_0.4.10 pkgconfig_2.0.3 prabclus_2.3-2 matrixStats_0.57.0 lattice_0.20-41
[85] purrr_0.3.4 rstantools_2.1.1 htmlwidgets_1.5.3 cowplot_1.1.0 tidyselect_1.1.0 processx_3.4.5
[91] plyr_1.8.6 magrittr_2.0.1 R6_2.5.0 generics_0.1.0 pillar_1.4.7 withr_2.3.0
[97] mgcv_1.8-34 xts_0.12.1 abind_1.4-5 nnet_7.3-15 tibble_3.0.4 crayon_1.3.4
[103] grid_4.0.4 callr_3.5.1 threejs_0.3.3 digest_0.6.27 diptest_0.75-7 xtable_1.8-4
[109] httpuv_1.5.5 RcppParallel_5.0.2 stats4_4.0.4 munsell_0.5.0 shinyjs_2.0.0

1 Like

Hi there, I think I have the same issue:

After updating all my R packages as well as RStudio today, using Ubuntu 20.04. When I call the brm() function, I get the following error:

make cmd is
make -f '/usr/lib/R/etc/Makeconf' -f '/usr/share/R/share/make/shlib.mk' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='filee0b38d717e9.so' OBJECTS='filee0b38d717e9.o'

make would use
if test "zfilee0b38d717e9.o" != "z"; then
echo g++ -std=gnu++14 -shared -L"/usr/lib/R/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -o filee0b38d717e9.so filee0b38d717e9.o '/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/rstan/lib//libStanServices.a' -L'/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/lib/' -lStanHeaders -L'/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/RcppParallel/lib/' -ltbb -L"/usr/lib/R/lib" -lR;
g++ -std=gnu++14 -shared -L"/usr/lib/R/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -o filee0b38d717e9.so filee0b38d717e9.o '/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/rstan/lib//libStanServices.a' -L'/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/lib/' -lStanHeaders -L'/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/RcppParallel/lib/' -ltbb -L"/usr/lib/R/lib" -lR;
fi
Error in compileCode(f, code, language = language, verbose = verbose) :
/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/include/src/stan/model/model_base_crtp.hpp:149:20: required from here/home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type’ {aka ‘__vector(2) double’} [-Wignored-attributes]/usr/bin/ld: /home/kdarras/R/x86_64-pc-linux-gnu-library/3.6/rstan/lib//libStanServices.a(stan_fit.o): relocation R_X86_64_PC32 against undefined hidden symbol `_ZTCN5boost10wrapexceptINS_4math14rounding_errorEEE0_NS_16exception_detail10clone_implINS4_19error_info_injectorIS2_EEEE' can not be used when making a shared object/usr/bin/ld: final link failed: bad valuecollect2: error: ld returned 1 exit statusmake: *** [/usr/share/R/share/make/shlib.mk:6: filee0b38d717e9.so] Error 1
In addition: Warning message:
Rows containing NAs were excluded from the model.
Error in sink(type = "output") : invalid connection
1 Like

@andrjohns have you heard of anyone else with linux problems since updating, and any ideas on what to do?

These errors are (lately) related to the BH package getting updated, and so the RStan and StanHeaders packages need to be recompiled against the latest version.

Try restarting R (and ensuring that RStan doesn’t get loaded) then reinstalling RStan and StanHeaders from source:

# Compile packages using all cores
Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))

install.packages(c("StanHeaders","rstan"),type="source")
3 Likes

@andrjohns that worked, thank you SO much! you’re a hero. @kdarras all good for you as well I hope?

Thank you @andrjohns! Indeed it worked for me, after skipping the first line of code that made my coputer crash every time I re-compiled rstan.

I wonder how hard it would be to search the return message on error for something like “undefined hidden symbol” and boost / Eigen to give a meaningful warning about this and tell users to do the reinstall