Skip to content

Commit cd9c3a4

Browse files
committed
aider: Depend on Python feature instead
I spent too much time goofing around with installing Python and pipx. Instead, let's just depend on the Python feature and be done with it! While it's not as efficient, it's a lot simpler and should support more Linux distributions.
1 parent 6721149 commit cd9c3a4

File tree

7 files changed

+14
-79
lines changed

7 files changed

+14
-79
lines changed

src/aider/devcontainer-feature.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"description": "Select an Aider version to install."
1717
}
1818
},
19+
"dependsOn": {
20+
"ghcr.io/devcontainers/features/python": {}
21+
},
1922
"installsAfter": [
2023
"ghcr.io/devcontainers/features/common-utils",
2124
"ghcr.io/devcontainers/features/python"

src/aider/install.sh

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,12 @@ detect_username() {
4343
# If there is no non-root user, use the default username.
4444
USERNAME=root
4545
fi
46-
elif [ "$USERNAME" = "none" ] || ! id -u "$USERNAME" &>/dev/null; then
46+
elif [ "$USERNAME" = none ] || ! id -u "$USERNAME" &>/dev/null; then
4747
# If the specified user does not exist or is unspecified, use default.
4848
USERNAME=root
4949
fi
5050
}
5151

52-
# Install Aider on Debian-based systems.
53-
install_debian() {
54-
if ! dpkg -l pipx &>/dev/null; then
55-
echo "pipx not found. Installing..."
56-
apt-get update && apt-get install -y pipx
57-
fi
58-
59-
if [ "$AIDER_VERSION" = latest ]; then
60-
echo "Installing latest Aider..."
61-
su -c 'pipx install aider-chat' "$USERNAME"
62-
else
63-
echo "Installing Aider version $AIDER_VERSION..."
64-
su -c "pipx install aider-chat==${AIDER_VERSION}" "$USERNAME"
65-
fi
66-
}
67-
68-
# Clean up
69-
clean_up() {
70-
case "$ADJUSTED_ID" in
71-
debian)
72-
rm -rf /var/lib/apt/lists/*
73-
;;
74-
*)
75-
echo "Unsupported distribution: $ADJUSTED_ID" >&2
76-
exit 1
77-
;;
78-
esac
79-
}
80-
8152
# Main entrypoint
8253
main() {
8354
if [ "$(id -u)" -ne 0 ]; then
@@ -86,35 +57,15 @@ main() {
8657
fi
8758

8859
detect_username
89-
90-
if [ ! -r /etc/os-release ]; then
91-
echo "Unsupported distribution: Unknown" >&2
92-
exit 1
93-
fi
94-
95-
# Read /etc/os-release to identify the Linux distribution
96-
# shellcheck disable=SC1091
97-
source /etc/os-release
98-
99-
# Ubuntu and other Debian-derivatives should be treated as Debian
100-
if [ "${ID_LIKE:-}" = debian ]; then
101-
ADJUSTED_ID=debian
60+
61+
if [ "$AIDER_VERSION" = latest ]; then
62+
echo "Installing latest Aider..."
63+
su -c 'pipx install aider-chat' "$USERNAME"
10264
else
103-
ADJUSTED_ID="${ID:-}"
65+
echo "Installing Aider version $AIDER_VERSION..."
66+
su -c "pipx install aider-chat==${AIDER_VERSION}" "$USERNAME"
10467
fi
10568

106-
case "$ADJUSTED_ID" in
107-
debian|ubuntu)
108-
install_debian
109-
;;
110-
*)
111-
echo "Unsupported distribution: $ADJUSTED_ID" >&2
112-
exit 1
113-
;;
114-
esac
115-
116-
clean_up
117-
11869
echo "Aider has been installed!"
11970
}
12071

test/aider/scenarios.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
},
1010
"remoteUser": "octocat"
1111
},
12-
"with_ubuntu": {
13-
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
14-
"features": {
15-
"aider": {}
16-
}
17-
},
1812
"with_version": {
1913
"image": "mcr.microsoft.com/devcontainers/base:debian",
2014
"features": {

test/aider/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ set -e
3535
# Optional: Import test library bundled with the devcontainer CLI
3636
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
3737
# Provides the 'check' and 'reportResults' commands.
38+
# shellcheck disable=SC1091
3839
source dev-container-features-test-lib
3940

4041
# Feature-specific tests

test/aider/with_ubuntu.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/aider/with_username.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
set -e
77

88
# Optional: Import test library bundled with the devcontainer CLI
9+
# shellcheck disable=SC1091
910
source dev-container-features-test-lib
1011

1112
# Feature-specific tests
1213
# The 'check' command comes from the dev-container-features-test-lib.
14+
# shellcheck disable=SC2016
1315
check "execute command" bash -c 'aider --version && [ $(whoami) = octocat ]'
1416

1517
# Report result

test/aider/with_version.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
set -e
77

88
# Optional: Import test library bundled with the devcontainer CLI
9+
# shellcheck disable=SC1091
910
source dev-container-features-test-lib
1011

1112
# Feature-specific tests

0 commit comments

Comments
 (0)