[Rcpp-devel] Rcpp / g++ ignoring TMPDIR

Dirk Eddelbuettel edd at debian.org
Mon Dec 2 03:33:46 CET 2013


Hi Jeroen,

On 1 December 2013 at 17:52, Jeroen Ooms wrote:
| Hi all :)
| 
| I'm experiencing an issue with building Rcpp packages inside the OpenCPU
| sandbox. I think this issue was introduced with the upgrade to Rcpp 0.10.6. The

I don't think this is us, and I don't think something changed. See below.

| problem is that g++ seems to ignore the TMPDIR environment variable, and
| instead always tries to use the default /tmp. When /tmp is not writable, this
| causes the compiling to fail.
| 
| I am personally using RAppArmor to enforce these security policies, but an
| easier way to reproduce the problem is by temporarily disable write access to /
| tmp. Something like this:
| 
| #force custom TMP directory, replace jeroen with your username
| cd /tmp
| sudo mkdir test
| sudo chown jeroen test
| sudo chgrp jeroen test
| sudo chmod 755 /tmp
| TMPDIR=/tmp/test bash -c R

This should pass through to shells spawned.  

First, straight bash:

  edd at max:~$ FOOBAR=/bing bash
  edd at max:~$ echo $FOOBAR
  /bing
  edd at max:~$ exit

Second, R

  edd at max:~$ FOOBAR=/bing R -q -e 'system("echo $FOOBAR")'
  R> system("echo $FOOBAR")
  /bing
  R> 
  R> 
  edd at max:~$

| #then in R do:
| tempdir() #check 
| install.packages("RcppExamples") #or any other rcpp package

Note that install.packages() is a base R function, and not anything Rcpp adds.
We do have a few system() calls here or there for Rcpp Attributes and the like.
 
| The process fails with 'Fatal error: creating temporary file for '-e' failed -L
| /usr/lib/R/lib -lR'. When using AppArmor, the error is actually more detailed
| and says that g++ tried to create a file /tmp/tmpfDbJ9KD. 
| 
| How can I make g++ use the same TMPDIR as the R process?

I think I'd start by setting TMPDIR. But here (in a virtual machine) I can't
even make g++ fail:

edd at billie:~/maxHome/tmp/jeroen$ cat hello.cpp 
#include <iostream>

int main(void) {
    std::cout << "Hello Jeroen\n";
    return 0;
}
edd at billie:~/maxHome/tmp/jeroen$ 

edd at billie:~/maxHome/tmp/jeroen$ g++ -o hello hello.cpp && ./hello
Hello Jeroen
edd at billie:~/maxHome/tmp/jeroen$ mkdir /tmp/test; sudo chown edd:edd /tmp/test; sudo chmod 0755 /tmp/test
edd at billie:~/maxHome/tmp/jeroen$ rm hello && TMPDIR=/tmp/test g++ -o hello hello.cpp && ./hello
Hello Jeroen
edd at billie:~/maxHome/tmp/jeroen$ 

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list