Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 8a22af2

Browse files
refactor(aider): improve dependency installation checks for Linux, ensuring tmux and screen are only installed if not present, and move checks for Python dependencies into Aider installation section
1 parent fa750d7 commit 8a22af2

File tree

1 file changed

+42
-21
lines changed

1 file changed

+42
-21
lines changed

aider/main.tf

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,26 +195,36 @@ resource "coder_script" "aider" {
195195
196196
# Install essential dependencies
197197
if [ "$(uname)" = "Linux" ]; then
198-
echo "Installing dependencies on Linux..."
199-
if command -v apt-get >/dev/null 2>&1; then
200-
sudo apt-get update -qq
201-
202-
# Install terminal multiplexers for persistent sessions
203-
if [ "${var.use_tmux}" = "true" ]; then
198+
echo "Checking dependencies for Linux..."
199+
200+
# Check and install tmux/screen only if needed and requested
201+
if [ "${var.use_tmux}" = "true" ]; then
202+
if ! command_exists tmux; then
204203
echo "Installing tmux for persistent sessions..."
205-
sudo apt-get install -y -qq python3-pip python3-venv tmux
204+
if command -v apt-get >/dev/null 2>&1; then
205+
sudo apt-get update -qq
206+
sudo apt-get install -y -qq tmux
207+
elif command -v dnf >/dev/null 2>&1; then
208+
sudo dnf install -y -q tmux
209+
else
210+
echo "Warning: Unable to install tmux on this system."
211+
fi
206212
else
207-
echo "Installing screen for persistent sessions..."
208-
sudo apt-get install -y -qq python3-pip python3-venv screen
213+
echo "tmux is already installed, skipping installation."
209214
fi
210-
elif command -v dnf >/dev/null 2>&1; then
211-
# For Red Hat-based distros
212-
if [ "${var.use_tmux}" = "true" ]; then
213-
echo "Installing tmux for persistent sessions..."
214-
sudo dnf install -y -q python3-pip python3-virtualenv tmux
215-
else
215+
elif [ "${var.use_screen}" = "true" ]; then
216+
if ! command_exists screen; then
216217
echo "Installing screen for persistent sessions..."
217-
sudo dnf install -y -q python3-pip python3-virtualenv screen
218+
if command -v apt-get >/dev/null 2>&1; then
219+
sudo apt-get update -qq
220+
sudo apt-get install -y -qq screen
221+
elif command -v dnf >/dev/null 2>&1; then
222+
sudo dnf install -y -q screen
223+
else
224+
echo "Warning: Unable to install screen on this system."
225+
fi
226+
else
227+
echo "screen is already installed, skipping installation."
218228
fi
219229
fi
220230
else
@@ -234,8 +244,23 @@ resource "coder_script" "aider" {
234244
if [ "${var.install_aider}" = "true" ]; then
235245
echo "Installing Aider..."
236246
247+
# Check if python3 and pip/venv are installed
248+
if ! command_exists python3 || ! command_exists pip3; then
249+
echo "Installing Python dependencies required for Aider..."
250+
if command -v apt-get >/dev/null 2>&1; then
251+
sudo apt-get update -qq
252+
sudo apt-get install -y -qq python3-pip python3-venv
253+
elif command -v dnf >/dev/null 2>&1; then
254+
sudo dnf install -y -q python3-pip python3-virtualenv
255+
else
256+
echo "Warning: Unable to install Python on this system."
257+
fi
258+
else
259+
echo "Python is already installed, skipping installation."
260+
fi
261+
237262
# Use official installation script
238-
if ! command -v aider &> /dev/null; then
263+
if ! command_exists aider; then
239264
curl -LsSf https://aider.chat/install.sh | sh
240265
fi
241266
@@ -304,8 +329,6 @@ CONVENTIONS_EOF
304329
echo "Running Aider with message in tmux session..."
305330
# Start aider with the message flag and yes-always to avoid confirmations
306331
tmux new-session -d -s ${var.session_name} -c ${var.folder} "echo \"Starting Aider with app status slug: aider\"; export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"; export CODER_MCP_APP_STATUS_SLUG=\"aider\"; aider --architect --yes-always --read CONVENTIONS.md --message \"Report each step to Coder. Your task: $CODER_MCP_AIDER_TASK_PROMPT\""
307-
# Create a flag file to indicate this task was executed
308-
touch "$HOME/.aider_task_executed"
309332
echo "Aider task started in tmux session '${var.session_name}'. Check the UI for progress."
310333
else
311334
# Create a new detached tmux session for interactive use
@@ -344,8 +367,6 @@ CONVENTIONS_EOF
344367
/bin/bash
345368
"
346369
347-
# Create a flag file to indicate this task was executed
348-
touch "$HOME/.aider_task_executed"
349370
echo "Aider task started in screen session '${var.session_name}'. Check the UI for progress."
350371
else
351372
# Create a new detached screen session for interactive use

0 commit comments

Comments
 (0)