From 3c4ebc3d8aa829b1ed6f4d4d87be0548c30e3229 Mon Sep 17 00:00:00 2001 From: Panduka Muditha Date: Thu, 24 Apr 2025 00:31:06 +0530 Subject: [PATCH] fix: Add error handling for scenarios where tmux is unavailable (#8043) Co-authored-by: Anuradha Weeraman --- Makefile | 10 ++++++++++ openhands/runtime/impl/local/local_runtime.py | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aebdf8d90b..398f8d99f0 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,7 @@ check-dependencies: ifeq ($(INSTALL_DOCKER),) @$(MAKE) -s check-docker endif + @$(MAKE) -s check-tmux @$(MAKE) -s check-poetry @echo "$(GREEN)Dependencies checked successfully.$(RESET)" @@ -101,6 +102,15 @@ check-docker: exit 1; \ fi +check-tmux: + @echo "$(YELLOW)Checking tmux installation...$(RESET)" + @if command -v tmux > /dev/null; then \ + echo "$(BLUE)$(shell tmux -V) is already installed.$(RESET)"; \ + else \ + echo "$(RED)tmux is not installed. Please install tmux to continue.$(RESET)"; \ + exit 1; \ + fi + check-poetry: @echo "$(YELLOW)Checking Poetry installation...$(RESET)" @if command -v poetry > /dev/null; then \ diff --git a/openhands/runtime/impl/local/local_runtime.py b/openhands/runtime/impl/local/local_runtime.py index f647b68fdd..3acc4d1886 100644 --- a/openhands/runtime/impl/local/local_runtime.py +++ b/openhands/runtime/impl/local/local_runtime.py @@ -68,7 +68,10 @@ def check_dependencies(code_repo_path: str, poetry_venvs_path: str): import libtmux server = libtmux.Server() - session = server.new_session(session_name='test-session') + try: + session = server.new_session(session_name='test-session') + except Exception as e: + raise ValueError('tmux is not properly installed or available on the path.') pane = session.attached_pane pane.send_keys('echo "test"') pane_output = '\n'.join(pane.cmd('capture-pane', '-p').stdout)