diff --git a/xmodule/capa/safe_exec/safe_exec.py b/xmodule/capa/safe_exec/safe_exec.py index bfc98bb22109..882db11fd1ef 100644 --- a/xmodule/capa/safe_exec/safe_exec.py +++ b/xmodule/capa/safe_exec/safe_exec.py @@ -31,7 +31,13 @@ # the ./tmp directory that codejail creates in each sandbox, rather than trying # to use a global temp dir (which should be blocked by AppArmor anyhow). # This is needed for matplotlib among other things. +# +# matplotlib will complain on stderr about the non-standard temp dir if we +# don't explicitly tell it "no really, use this". This pollutes the output +# when codejail returns an error message (which includes stderr). So we also +# set MPLCONFIGDIR as a special case. os.environ["TMPDIR"] = os.getcwd() + "/tmp" +os.environ["MPLCONFIGDIR"] = os.environ["TMPDIR"] import random2 as random_module import sys