Pkgbuild::compile_dll() with stan models fails due to permissions in /tmp, solutions not working

I’m having the problem with my /tmp directory being set with noexec (so scripts inside it can’t be executed). This is causing pkgbuild::compile_dll() to fail when building an R package with Stan models. I’ve tried to fix this a number of ways.

I created a new folder called ~/rtmp and set TMPDIR=~/rtmp. This worked in the sense that temporary files were created inside the new folder, but compile_dll() still fails with the same error.

I did sudo chmod 777 ~/rtmp and sudo chmod -R 777 ~/rtmp and those also failed—the change didn’t apply to the new file that was created by compile_dll().

Here’s what it all looks like after creating a fresh rtmp directory and giving it full permissions with chmod as above:

Re-compiling spstan
─ installing source package ‘spstan’ …
** using staged installation
ERROR: ‘configure’ exists but is not executable – see the ‘R Installation and Administration Manual’
─ removing ‘/home/connor/rtmp/RtmpPVXJ8C/devtools_install_5d8d388b0a4b/spstan’
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command error

Then looking at the contents and permissions of ~/rtmp:

connor@xps:~$ ls -l rtmp/RtmpPVXJ8C
total 40
drwxrwxrwx 2 connor connor 4096 Jun 24 17:42 devtools_install_5d8d388b0a4b
-rw-rw-rw- 1 connor connor 327 Jun 24 17:42 file5d8d1562eae6
-rw-rw-rw- 1 connor connor 327 Jun 24 17:42 file5d8d1a3a36b
-rw-rw-rw- 1 connor connor 200 Jun 24 17:42 file5d8d22b9e7a9
-rw-rw-rw- 1 connor connor 2305 Jun 24 17:42 file5d8d382ad0bc
-rw-rw-rw- 1 connor connor 780 Jun 24 17:42 file5d8d4b931938
-rw-rw-rw- 1 connor connor 200 Jun 24 17:42 file5d8d5a60119b
-rw-rw-rw- 1 connor connor 2304 Jun 24 17:42 file5d8d5eb353c1
-rw-rw-rw- 1 connor connor 781 Jun 24 17:42 file5d8d776cca6b
-rw-rw-rw- 1 connor connor 2608 Jun 24 17:42 foo.o

Any ideas for how to address this?

The need to manually set TMPDIR was previously discussed here RStan and PyStan may fail to compile model if TMPDIR not manually set

and I also posted this with some other details at stackoverflow but haven’t gotten any response

I also tried this with ~/rtmp mounted as a proper temporary directory (by adding it to my /etc/fstab file and rebooting), but that didn’t help.

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 compiler_3.6.0 pillar_1.4.1
[4] prettyunits_1.0.2 tools_3.6.0 pkgbuild_1.0.3
[7] tibble_2.1.2 gtable_0.3.0 lattice_0.20-38
[10] pkgconfig_2.0.2 rlang_0.3.4 Matrix_1.2-17
[13] cli_1.1.0 parallel_3.6.0 loo_2.1.0
[16] gridExtra_2.3 dplyr_0.8.1 desc_1.2.0
[19] stats4_3.6.0 rprojroot_1.3-2 grid_3.6.0
[22] tidyselect_0.2.5 inline_0.3.15 glue_1.3.1
[25] R6_2.4.0 processx_3.3.1 BH_1.69.0-1
[28] rstan_2.18.2 ggplot2_3.2.0 callr_3.2.0
[31] purrr_0.3.2 magrittr_1.5 matrixStats_0.54.0
[34] backports_1.1.4 scales_1.0.0 ps_1.3.0
[37] StanHeaders_2.18.1-10 assertthat_0.2.1 colorspace_1.4-1
[40] lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4
[43] RcppEigen_0.

We haven’t considered this case. I’ll try to look into it.

I decided to reinstall Ubuntu. Previously this was a general problem, not just with pkgbuild but also installing certain packages with c++ to compile or that use Rcpp I think.

See where this same issue is discussed. There were problems using devtools::install_github The reproducible example was with devtools::install_github("cboettig/mcmcTools")

Previously that failed for me too with the same error message as compile_dll(). After the fresh install of Ubuntu 18.04 this example works, as does my own package install devtools::install_github("ConnorDonegan/spstan", "37763e1"), and the Stan models work.

But compile_dll() still fails.

I installed mcmcTools without first setting TMPDIR, so it used /tmp instead of ~/tmp. So I tried compile_dll() and it failed; then created ~/tmp and tried again; then changed permission of ~/tmp and again it failed with the same message.

I’m wondering if this could be a result of something Dell did to Ubuntu. They installed this version on my laptop with all the needed drivers etc. for the xps 13 and who know what else. So I guess I’ll try this again while booting from a regular Ubuntu distribution

1 Like