("[Errno 2] No such file or directory: 'TMPDIR=tmp'", )

Hi I’m having troubles with the demo courses,

2 Likes

Hi. Did you modify the block?
The error message mentions the „script code“. You can inspect what’s that script’s code, clicking EDITAR and seeing whether there’s something written there that is trying to access files. For instance, when I tried it, I saw a <script type="loncapa/python"> section with Python code.

It may be that Open edX isn’t correctly installed and doesn’t have access to a /tmp directory.
You can provide more details about how you installed it.

I think the easiest solution is to experiment more, in many ways: for instance: try to add a new „molecule editor“ yourself, and see what happens. Try to compare a broken block vs. a working block. Find other blocks which are failing, etc.

You may also try exporting the course, to inspect it in more detail.

1 Like

The same issue is reported here during #working-groups:build-test-release 's olive testing.

I’m running into this same error on a Kubernetes deployment that’s running Codejail.

2024-02-08 17:02:24,333 INFO 13 [tracking] [user 52] [ip 192.168.6.57] logger.py:41 - {"name": "/xblock/block-v1:StepWiseMath+OSPCL0501+2022_RevA+type@vertical+block@54a88cb2c47811ee8147a9e3790c0be7/container_preview", "context": {"user_id": 52, "path": "/xblock/block-v1:StepWiseMath+OSPCL0501+2022_RevA+type@vertical+block@54a88cb2c47811ee8147a9e3790c0be7/container_preview", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "mcdaniel", "session": "9e6abfd35912a8e3eae22defd5ab5927", "ip": "192.168.6.57", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "host": "studio.staging.stepwisemath.ai", "referer": "https://studio.staging.stepwisemath.ai/container/block-v1:StepWiseMath+OSPCL0501+2022_RevA+type@vertical+block@54a88cb2c47811ee8147a9e3790c0be7", "accept_language": "en-GB,en-US;q=0.9,en;q=0.8,es-ES;q=0.7,es;q=0.6", "event": "{\"GET\": {\"_\": [\"1707411744096\"]}, \"POST\": {}}", "time": "2024-02-08T17:02:24.332901+00:00", "event_type": "/xblock/block-v1:StepWiseMath+OSPCL0501+2022_RevA+type@vertical+block@54a88cb2c47811ee8147a9e3790c0be7/container_preview", "event_source": "server", "page": null}
2024-02-08 17:02:24,489 INFO 13 [codejail] [user 52] [ip 192.168.6.57] jail_code.py:295 - Preparing to execute jailed code '54ea23e6c47811ee821fa9e3790c0be7' (overrides context = 'course-v1:StepWiseMath+OSPCL0501+2022_RevA', resource limits = {'CPU': 1, 'REALTIME': 1, 'VMEM': 0, 'FSIZE': 0, 'NPROC': 15, 'PROXY': None}).
2024-02-08 17:02:24,511 ERROR 13 [xmodule.capa.capa_problem] [user 52] [ip 192.168.6.57] capa_problem.py:945 - Error while execing script code: 

p1,p2,p3,p4,p5,p6="false","false","false","false","false","false"
case = random.randrange(0,6)
if case==1: 
  angle,p1,dir=30,"true","clockwise" 
elif case==2: 
  angle,p2,dir=300,"true","clockwise"
elif case==3: 
  angle,p3,dir=135,"true","clockwise"
elif case==4: 
  angle,p4,dir=-150,"true","counter-clockwise"
elif case==5: 
  angle,p5,dir=120,"true","clockwise"
else: 
  angle,p6,dir=-80,"true","counter-clockwise"



Traceback (most recent call last):
  File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 931, in _extract_context
    safe_exec(
  File "/opt/pyenv/versions/3.8.15/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/openedx/edx-platform/xmodule/capa/safe_exec/safe_exec.py", line 170, in safe_exec
    exec_fn(
  File "/openedx/venv/lib/python3.8/site-packages/codejail/safe_exec.py", line 152, in safe_exec
    res = jail_code.jail_code(
  File "/openedx/venv/lib/python3.8/site-packages/codejail/jail_code.py", line 317, in jail_code
    status, stdout, stderr = run_subprocess_fn(
  File "/openedx/venv/lib/python3.8/site-packages/codejail/subproc.py", line 39, in run_subprocess
    subproc = subprocess.Popen(  # pylint: disable=subprocess-popen-preexec-fn
  File "/opt/pyenv/versions/3.8.15/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/pyenv/versions/3.8.15/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'TMPDIR=tmp'
2024-02-08 17:02:24,512 ERROR 13 [edx.courseware] [user 52] [ip 192.168.6.57] capa_block.py:945 - LcpFatalError Encountered for block-v1:StepWiseMath+OSPCL0501+2022_RevA+type@problem+block@54ea23e6c47811ee821fa9e3790c0be7
Traceback (most recent call last):
  File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 931, in _extract_context
    safe_exec(
  File "/opt/pyenv/versions/3.8.15/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/openedx/edx-platform/xmodule/capa/safe_exec/safe_exec.py", line 170, in safe_exec
    exec_fn(
  File "/openedx/venv/lib/python3.8/site-packages/codejail/safe_exec.py", line 152, in safe_exec
    res = jail_code.jail_code(
  File "/openedx/venv/lib/python3.8/site-packages/codejail/jail_code.py", line 317, in jail_code
    status, stdout, stderr = run_subprocess_fn(
  File "/openedx/venv/lib/python3.8/site-packages/codejail/subproc.py", line 39, in run_subprocess
    subproc = subprocess.Popen(  # pylint: disable=subprocess-popen-preexec-fn
  File "/opt/pyenv/versions/3.8.15/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/pyenv/versions/3.8.15/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'TMPDIR=tmp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/openedx/edx-platform/xmodule/capa_block.py", line 788, in lcp
    lcp = self.new_lcp(self.get_state_for_lcp())
  File "/openedx/edx-platform/xmodule/capa_block.py", line 846, in new_lcp
    return LoncapaProblem(
  File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 209, in __init__
    self.context = self._extract_context(self.tree)
  File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 947, in _extract_context
    raise responsetypes.LoncapaProblemError(msg)
xmodule.capa.responsetypes.LoncapaProblemError: Error while executing script code: [Errno 2] No such file or directory: &#39;TMPDIR=tmp&#39;

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/openedx/edx-platform/xmodule/capa_block.py", line 359, in student_view
    self.lcp
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/openedx/edx-platform/xmodule/capa_block.py", line 792, in lcp
    raise LoncapaProblemError(msg).with_traceback(sys.exc_info()[2])
  File "/openedx/edx-platform/xmodule/capa_block.py", line 788, in lcp
    lcp = self.new_lcp(self.get_state_for_lcp())
  File "/openedx/edx-platform/xmodule/capa_block.py", line 846, in new_lcp
    return LoncapaProblem(
  File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 209, in __init__
    self.context = self._extract_context(self.tree)
  File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 947, in _extract_context
    raise responsetypes.LoncapaProblemError(msg)
xmodule.capa.responsetypes.LoncapaProblemError: cannot create LoncapaProblem block-v1:StepWiseMath+OSPCL0501+2022_RevA+type@problem+block@54ea23e6c47811ee821fa9e3790c0be7: Error while executing script code: [Errno 2] No such file or directory: &#39;TMPDIR=tmp&#39;

Hi,

I am running into this issue now, on openedx installed via Tutor (I have no idea which version is running, I installed it only a couple of days ago so I’d assume the latest).

Every time I add a ‘Custom Python Evaluated Input’ block I get the following error:

cannot create LoncapaProblem block-v1:[my-site-course-etc]@problem+block@941921a9aef94b5ca0ae442e7d9a02ac: Error while executing script code: [Errno 2] No such file or directory: &#39;TMPDIR=tmp&#39;

When I look at the logs, I get the following:

2024-03-26 10:33:06,078 ERROR 7 [xmodule.capa.capa_problem] [user 4] [ip 195.166.220.63] capa_problem.py:944 - Error while execing script code: 
cms-1            | 
cms-1            | def test_add_to_ten(expect, ans):
cms-1            |     return test_add(10, ans)
cms-1            | 
cms-1            | 
cms-1            | 
cms-1            | def test_add(expect, ans):
cms-1            |     try:
cms-1            |         a1=int(ans[0])
cms-1            |         a2=int(ans[1])
cms-1            |         return (a1+a2) == int(expect)
cms-1            |     except ValueError:
cms-1            |         return False
cms-1            | 
cms-1            | Traceback (most recent call last):
cms-1            |   File "/openedx/edx-platform/xmodule/capa/capa_problem.py", line 930, in _extract_context
cms-1            |     safe_exec(
cms-1            |   File "/opt/pyenv/versions/3.8.18/lib/python3.8/contextlib.py", line 75, in inner
cms-1            |     return func(*args, **kwds)
cms-1            |   File "/openedx/edx-platform/xmodule/capa/safe_exec/safe_exec.py", line 166, in safe_exec
cms-1            |     exec_fn(
cms-1            |   File "/openedx/venv/lib/python3.8/site-packages/codejail/safe_exec.py", line 152, in safe_exec
cms-1            |     res = jail_code.jail_code(
cms-1            |   File "/openedx/venv/lib/python3.8/site-packages/codejail/jail_code.py", line 317, in jail_code
cms-1            |     status, stdout, stderr = run_subprocess_fn(
cms-1            |   File "/openedx/venv/lib/python3.8/site-packages/codejail/subproc.py", line 39, in run_subprocess
cms-1            |     subproc = subprocess.Popen(  # pylint: disable=subprocess-popen-preexec-fn
cms-1            |   File "/opt/pyenv/versions/3.8.18/lib/python3.8/subprocess.py", line 858, in __init__
cms-1            |     self._execute_child(args, executable, preexec_fn, close_fds,
cms-1            |   File "/opt/pyenv/versions/3.8.18/lib/python3.8/subprocess.py", line 1720, in _execute_child
cms-1            |     raise child_exception_type(errno_num, err_msg, err_filename)
cms-1            | FileNotFoundError: [Errno 2] No such file or directory: 'TMPDIR=tmp'

So it’s something to do with permissions and running processes in the docker container, does anyone know of a solution? I have scanned this site for a solution but this thread is the closest one I could find so far.

In the half hour since I posted, I may have answered my own question.

There is already an issue open in the codejail repo for this exact issue:
codejail issue 162

It also seems that tutor doesn’t support codejail:
tutor references disabling codejail as a default

What I don’t know though, is if codejail is completely unsupported or I just need to do some additional setup. Does anyone know?