Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: Add error handling for scenarios where tmux is unavailable (#8043)

Panduka Muditha3c4ebc3d8aa8
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)