easystats / modelbased

:chart_with_upwards_trend: Estimate effects, contrasts and means based on statistical models
https://easystats.github.io/modelbased/
GNU General Public License v3.0
232 stars 19 forks source link

Tests fail to find TBB installation: `Library not loaded: @rpath/libtbb.dylib`, which break several `brms`-related tests [ FAIL 6 | WARN 0 | SKIP 3 | PASS 165 ] #259

Closed barracuda156 closed 3 weeks ago

barracuda156 commented 3 weeks ago

There are a few errors in tests:

--->  Testing R-modelbased
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/modelbased" && /opt/local/bin/R CMD check ./modelbased_0.8.8.tar.gz --no-manual --no-build-vignettes 
* using log directory ‘/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/modelbased/modelbased.Rcheck’
* using R version 4.4.0 (2024-04-24)
* using platform: powerpc-apple-darwin10.0.0d2 (32-bit)
* R was compiled by
    gcc-mp-13 (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0
    GNU Fortran (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0
* running under: OS X Snow Leopard 10.6
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘modelbased/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘modelbased’ version ‘0.8.8’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘modelbased’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking ‘build’ directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking code files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking files in ‘vignettes’ ... OK
* checking examples ... OK
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ...
  Running ‘testthat.R’
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
    7.             └─brms (local) .compile_model(model, ...)
    8.               ├─brms:::eval_silent(...)
    9.               │ └─base::eval(expr, envir)
   10.               │   └─base::eval(expr, envir)
   11.               └─brms::do_call(rstan::stan_model, args)
   12.                 └─brms:::eval2(call, envir = args, enclos = envir)
   13.                   └─base::eval(expr, envir, ...)
   14.                     └─base::eval(expr, envir, ...)
   15.                       └─rstan (local) .fun(model_code = .x1)
   16.                         └─rstan:::cxxfunctionplus(...)
   17.                           └─base::sink(type = "output")

  [ FAIL 6 | WARN 0 | SKIP 3 | PASS 165 ]
  Error: Test failures
  Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes ... OK
* checking running R code from vignettes ...
  ‘overview_of_vignettes.Rmd’ using ‘UTF-8’... OK
 OK
* checking re-building of vignette outputs ... SKIPPED
* DONE

Specifically:


R version 4.4.0 (2024-04-24) -- "Puppy Cup"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: powerpc-apple-darwin10.0.0d2 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> # This file is part of the standard setup for testthat.
> # It is recommended that you do not modify it.
> #
> # Where should you do additional test configuration?
> #
> # * https://r-pkgs.org/tests.html
> # * https://testthat.r-lib.org/reference/test_package.html#special-files
> library(testthat)
> library(modelbased)
> 
> test_check("modelbased")
Starting 2 test processes
Superclass process has cloneable=FALSE, but subclass r_session has cloneable=TRUE. A subclass cannot be cloneable when its superclass is not cloneable, so cloning will be disabled for r_session.
Superclass process has cloneable=FALSE, but subclass r_session has cloneable=TRUE. A subclass cannot be cloneable when its superclass is not cloneable, so cloning will be disabled for r_session.
[ FAIL 6 | WARN 0 | SKIP 3 | PASS 165 ]

══ Skipped tests (3) ═══════════════════════════════════════════════════════════
• .Platform$OS.type == "windows" is not TRUE (1):
  'test-estimate_predicted.R:56:3'
• On Mac (1): 'test-mgcv.R:55:3'
• empty test (1): 'test-estimate_contrasts.R:189:1'

══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-brms.R:6:3'): estimate_means - brms ────────────────────────────
Error in `dyn.load(libLFile)`: unable to load shared object '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file94026a68b396.so':
  dlopen(/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file94026a68b396.so, 6): Library not loaded: @rpath/libtbb.dylib
  Referenced from: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file94026a68b396.so
  Reason: image not found
Backtrace:
     ▆
  1. └─brms::brm(...) at test-brms.R:6:3
  2.   └─brms::do_call(compile_model, compile_args)
  3.     └─brms:::eval2(call, envir = args, enclos = envir)
  4.       └─base::eval(expr, envir, ...)
  5.         └─base::eval(expr, envir, ...)
  6.           └─brms (local) .fun(...)
  7.             └─brms (local) .compile_model(model, ...)
  8.               ├─brms:::eval_silent(...)
  9.               │ └─base::eval(expr, envir)
 10.               │   └─base::eval(expr, envir)
 11.               └─brms::do_call(rstan::stan_model, args)
 12.                 └─brms:::eval2(call, envir = args, enclos = envir)
 13.                   └─base::eval(expr, envir, ...)
 14.                     └─base::eval(expr, envir, ...)
 15.                       └─rstan (local) .fun(model_code = .x1)
 16.                         └─rstan:::cxxfunctionplus(...)
 17.                           ├─pkgbuild::with_build_tools(...)
 18.                           └─inline::cxxfunction(...)
 19.                             └─base::dyn.load(libLFile)
── Error ('test-brms.R:6:3'): estimate_means - brms ────────────────────────────
Error in `sink(type = "output")`: invalid connection
Backtrace:
     ▆
  1. └─brms::brm(...) at test-brms.R:6:3
  2.   └─brms::do_call(compile_model, compile_args)
  3.     └─brms:::eval2(call, envir = args, enclos = envir)
  4.       └─base::eval(expr, envir, ...)
  5.         └─base::eval(expr, envir, ...)
  6.           └─brms (local) .fun(...)
  7.             └─brms (local) .compile_model(model, ...)
  8.               ├─brms:::eval_silent(...)
  9.               │ └─base::eval(expr, envir)
 10.               │   └─base::eval(expr, envir)
 11.               └─brms::do_call(rstan::stan_model, args)
 12.                 └─brms:::eval2(call, envir = args, enclos = envir)
 13.                   └─base::eval(expr, envir, ...)
 14.                     └─base::eval(expr, envir, ...)
 15.                       └─rstan (local) .fun(model_code = .x1)
 16.                         └─rstan:::cxxfunctionplus(...)
 17.                           └─base::sink(type = "output")
── Error ('test-brms.R:14:3'): estimate_relation - brms ────────────────────────
Error in `dyn.load(libLFile)`: unable to load shared object '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file9402139d351d.so':
  dlopen(/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file9402139d351d.so, 6): Library not loaded: @rpath/libtbb.dylib
  Referenced from: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file9402139d351d.so
  Reason: image not found
Backtrace:
     ▆
  1. └─brms::brm(...) at test-brms.R:14:3
  2.   └─brms::do_call(compile_model, compile_args)
  3.     └─brms:::eval2(call, envir = args, enclos = envir)
  4.       └─base::eval(expr, envir, ...)
  5.         └─base::eval(expr, envir, ...)
  6.           └─brms (local) .fun(...)
  7.             └─brms (local) .compile_model(model, ...)
  8.               ├─brms:::eval_silent(...)
  9.               │ └─base::eval(expr, envir)
 10.               │   └─base::eval(expr, envir)
 11.               └─brms::do_call(rstan::stan_model, args)
 12.                 └─brms:::eval2(call, envir = args, enclos = envir)
 13.                   └─base::eval(expr, envir, ...)
 14.                     └─base::eval(expr, envir, ...)
 15.                       └─rstan (local) .fun(model_code = .x1)
 16.                         └─rstan:::cxxfunctionplus(...)
 17.                           ├─pkgbuild::with_build_tools(...)
 18.                           └─inline::cxxfunction(...)
 19.                             └─base::dyn.load(libLFile)
── Error ('test-brms.R:14:3'): estimate_relation - brms ────────────────────────
Error in `sink(type = "output")`: invalid connection
Backtrace:
     ▆
  1. └─brms::brm(...) at test-brms.R:14:3
  2.   └─brms::do_call(compile_model, compile_args)
  3.     └─brms:::eval2(call, envir = args, enclos = envir)
  4.       └─base::eval(expr, envir, ...)
  5.         └─base::eval(expr, envir, ...)
  6.           └─brms (local) .fun(...)
  7.             └─brms (local) .compile_model(model, ...)
  8.               ├─brms:::eval_silent(...)
  9.               │ └─base::eval(expr, envir)
 10.               │   └─base::eval(expr, envir)
 11.               └─brms::do_call(rstan::stan_model, args)
 12.                 └─brms:::eval2(call, envir = args, enclos = envir)
 13.                   └─base::eval(expr, envir, ...)
 14.                     └─base::eval(expr, envir, ...)
 15.                       └─rstan (local) .fun(model_code = .x1)
 16.                         └─rstan:::cxxfunctionplus(...)
 17.                           └─base::sink(type = "output")
── Error ('test-brms.R:25:3'): estimate_means - brms ───────────────────────────
Error in `dyn.load(libLFile)`: unable to load shared object '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file94024b1a703e.so':
  dlopen(/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file94024b1a703e.so, 6): Library not loaded: @rpath/libtbb.dylib
  Referenced from: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-modelbased/R-modelbased/work/.tmp/RtmpVVGndh/file94024b1a703e.so
  Reason: image not found
Backtrace:
     ▆
  1. └─brms::brm(...) at test-brms.R:25:3
  2.   └─brms::do_call(compile_model, compile_args)
  3.     └─brms:::eval2(call, envir = args, enclos = envir)
  4.       └─base::eval(expr, envir, ...)
  5.         └─base::eval(expr, envir, ...)
  6.           └─brms (local) .fun(...)
  7.             └─brms (local) .compile_model(model, ...)
  8.               ├─brms:::eval_silent(...)
  9.               │ └─base::eval(expr, envir)
 10.               │   └─base::eval(expr, envir)
 11.               └─brms::do_call(rstan::stan_model, args)
 12.                 └─brms:::eval2(call, envir = args, enclos = envir)
 13.                   └─base::eval(expr, envir, ...)
 14.                     └─base::eval(expr, envir, ...)
 15.                       └─rstan (local) .fun(model_code = .x1)
 16.                         └─rstan:::cxxfunctionplus(...)
 17.                           ├─pkgbuild::with_build_tools(...)
 18.                           └─inline::cxxfunction(...)
 19.                             └─base::dyn.load(libLFile)
── Error ('test-brms.R:25:3'): estimate_means - brms ───────────────────────────
Error in `sink(type = "output")`: invalid connection
Backtrace:
     ▆
  1. └─brms::brm(...) at test-brms.R:25:3
  2.   └─brms::do_call(compile_model, compile_args)
  3.     └─brms:::eval2(call, envir = args, enclos = envir)
  4.       └─base::eval(expr, envir, ...)
  5.         └─base::eval(expr, envir, ...)
  6.           └─brms (local) .fun(...)
  7.             └─brms (local) .compile_model(model, ...)
  8.               ├─brms:::eval_silent(...)
  9.               │ └─base::eval(expr, envir)
 10.               │   └─base::eval(expr, envir)
 11.               └─brms::do_call(rstan::stan_model, args)
 12.                 └─brms:::eval2(call, envir = args, enclos = envir)
 13.                   └─base::eval(expr, envir, ...)
 14.                     └─base::eval(expr, envir, ...)
 15.                       └─rstan (local) .fun(model_code = .x1)
 16.                         └─rstan:::cxxfunctionplus(...)
 17.                           └─base::sink(type = "output")

[ FAIL 6 | WARN 0 | SKIP 3 | PASS 165 ]
Error: Test failures
Execution halted

I am not sure what Error insink(type = "output"): invalid connection stands for, but from the dyld errors it looks like the tests are building stuff, and use @rpath for that, which is prone to failures:

Library not loaded: @rpath/libtbb.dylib

There may be several TBB libraries installed, and/or it may be installed in a non-default location, so the correct behavior would be to use an absolute path, controlled by a configure argument. It if is supposed to use RcppParallel implementation, then it fails to find it.

Could we address this?

DominiqueMakowski commented 3 weeks ago

The sink output looks like a brms/rstan issue

barracuda156 commented 3 weeks ago

@paul-buerkner Could you please help us here? The error might be related to how brms builds model objects: what we need to make it work is to not use @rpath but instead use the absolute path to TBB. Could you say how to do that?

DominiqueMakowski commented 3 weeks ago

As this doesn't seem to be a modelbased-specific issue, I would recommend posting on the stan forums where you might get more help

barracuda156 commented 3 weeks ago

Just for the the reference, the issue was caused by RcppParallel, and once fixed, Rstan works correctly and tests pass.

I will submit a fix to MacPorts.