[Errno 2] No such file or directory: 'TMPDIR=tmp

Hi,
I am running the Demo course when i try to submit a solution for the chemistry question i get the following error
[Errno 2] No such file or directory: ‘TMPDIR=tmp’

Hi,

I am getting a similar error when I try to add Custom Python-Evaluated Input

  • I go to Studio → Course → Content → Outline → Section → Subsection → Unit
  • Add New Component → Problem → Advanced → Custom Python-Evaluated Input

Here is the output

Error formatting HTML for problem:

cannot create LoncapaProblem block-v1:<course>+type@problem+block@4f2fcbefaca84277ad79aae37c9a533d: Error while executing script code: [Errno 2] No such file or directory: &#39;TMPDIR=tmp&#39;

The same happens with Custom JavaScript Display and Grading

I think it’s a tutor bug same error can be seen at demo.overhang.io

1 Like

I’m getting the same issue when creating a new “Custom JavaScript Display and Grading” block and for existing ones that were working before the upgrade to Lilac. The full error message is this:

Error formatting HTML for problem:

cannot create LoncapaProblem block-<course id>+type@problem+block@<some hash>: Error while executing script code: [Errno 2] No such file or directory: &#39;TMPDIR=tmp&#39;

I’ve tried looking in the Tutor and Open edX code for TMPDIR but no luck, so the issue might be somewhat deeper. I’m not sure it’s an issue with looking for a directory named tmp, or looking for a directory named TMPDIR=tmp which is silly.

Here is the full traceback:

lms_1            | 2021-09-01 13:38:52,757 INFO 120 [codejail] [user 5] [ip 172.21.0.1] jail_code.py:296 - Preparing to execute jailed code 'Sample_ChemFormula_Problem_1' (overrides context = None, resource limi
ts = {'CPU': 1, 'REALTIME': 1, 'VMEM': 0, 'FSIZE': 0, 'NPROC': 15, 'PROXY': None}).
lms_1            | 2021-09-01 13:38:52,769 WARNING 120 [capa.responsetypes] [user 5] [ip 172.21.0.1] responsetypes.py:2521 - Error occurred while evaluating CustomResponse
lms_1            | Traceback (most recent call last):
lms_1            |   File "/openedx/edx-platform/common/lib/capa/capa/responsetypes.py", line 2299, in execute_check_function
lms_1            |     safe_exec.safe_exec(
lms_1            |   File "/openedx/edx-platform/common/lib/capa/capa/safe_exec/safe_exec.py", line 152, in safe_exec
lms_1            |     exec_fn(
lms_1            |   File "/openedx/venv/src/codejail/codejail/safe_exec.py", line 154, in safe_exec
lms_1            |     res = jail_code.jail_code(
lms_1            |   File "/openedx/venv/src/codejail/codejail/jail_code.py", line 318, in jail_code
lms_1            |     status, stdout, stderr = run_subprocess_fn(
lms_1            |   File "/openedx/venv/src/codejail/codejail/subproc.py", line 39, in run_subprocess
lms_1            |     subproc = subprocess.Popen(  # pylint: disable=subprocess-popen-preexec-fn
lms_1            |   File "/opt/pyenv/versions/3.8.6/lib/python3.8/subprocess.py", line 854, in __init__
lms_1            |     self._execute_child(args, executable, preexec_fn, close_fds,
lms_1            |   File "/opt/pyenv/versions/3.8.6/lib/python3.8/subprocess.py", line 1702, in _execute_child
lms_1            |     raise child_exception_type(errno_num, err_msg, err_filename)
lms_1            | FileNotFoundError: [Errno 2] No such file or directory: 'TMPDIR=tmp'

The TMPDIR variable is actually declared in the codejail package: codejail/jail_code.py at babbe784b48bb9888aa159d8b401cbe5e07f0af4 · edx/codejail · GitHub

Tutor explicitely disabled codejail in v11.3.0 for security reasons. This is Custom Python-Evaluated Input is crashing (including the chemical equation problem).

To be fair, edx-platform should crash with a more explicit error message. This specific error is reported in Tutor, and not in the native installation, because the latter prefixes the python command with sudo ..., which causes environment variables declared as KEY=value to be correctly interpreted. sudo is used in the native installation because the CODE_JAIL["user"] is not None. When we define CODE_JAIL["user"] = "nonexistinguser" in Tutor, codejail then crashes with the following error:

capa.responsetypes.ResponseError: ("[Errno 2] No such file or directory: 'sudo'", <traceback object at 0x7fd184aa6c00>)

This is because sudo is not present in the Tutor Docker image. When we install sudo in the Docker image, the error becomes:

capa.responsetypes.ResponseError: ("Couldn't execute jailed code: stdout: b'', stderr: b'sudo: unknown user: nonexistinguser\\nsudo: unable to initialize policy plugin\\n' with status code: 1", <traceback object at 0x7fd1a44ede80>)

Which is a little bit more explicit (but still not great).

Codejail will soon be supported in Tutor, thanks to a wonderful plugin currently in development by @eric.herrera : Codejail REST API service Flask - MVP by ericfab179 · Pull Request #2 · eduNEXT/codejailservice · GitHub</title I recommend everyone in this thread to give it a try right now.

2 Likes

Today I’ve tried to install codejail but the main branches of codejailservice and tutor-contrib-codejail are void (just README.rst). Manually downloading and installing from eric/mvp branch didn’t worked. Python installation seems to be ok but the plugin is not listed using tutor plugins list.