Skip to content

Commit 57aa66e

Browse files
sjarmakclaude
andcommitted
Fix chown patch: edit installed source instead of monkey-patching
The action_execution_server runs as a separate subprocess that doesn't inherit our monkey-patches. Replace 'chown -R' with 'true #chown -R' in the installed runtime_init.py source file so the fix takes effect in the server subprocess too. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 37f0448 commit 57aa66e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

agents/harnesses/openhands/agent.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,14 @@ def create_run_agent_commands(self, instruction: str):
227227
"# recursive chown is a no-op that takes >120s on large repos (firefox,",
228228
"# linux, etc.), causing the action_execution_server to miss its startup",
229229
"# deadline and the OH client to throw ConnectError.",
230-
"import openhands.runtime.utils.runtime_init as _ri_mod",
231-
"def _noop_init_user(**kw): return kw.get('user_id', 0)",
232-
"_ri_mod.init_user_and_working_directory = _noop_init_user",
233-
"# Also patch the server module's imported reference",
234-
"import openhands.runtime.action_execution_server as _aes_mod",
235-
"if hasattr(_aes_mod, 'init_user_and_working_directory'):",
236-
" _aes_mod.init_user_and_working_directory = _noop_init_user",
230+
"# The server runs as a SEPARATE subprocess, so we patch the installed",
231+
"# source file to replace 'chown -R' with a no-op 'true' command.",
232+
"import glob as _glob",
233+
"for _ri_path in _glob.glob('/opt/openhands-venv/lib/python*/site-packages/openhands/runtime/utils/runtime_init.py'):",
234+
" _ri_src = open(_ri_path).read()",
235+
" if 'chown -R' in _ri_src:",
236+
" _ri_src = _ri_src.replace('chown -R', 'true #chown -R')",
237+
" with open(_ri_path, 'w') as _f: _f.write(_ri_src)",
237238
"",
238239
"runpy.run_module('openhands.core.main', run_name='__main__')",
239240
])

0 commit comments

Comments
 (0)