Skip to content

Commit 0e717bc

Browse files
feat: auto-install VS Code on Ubuntu for spill-proof setup (#1437)
* feat: install vscode on apt systems when missing * Update setup.sh Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> * Update setup.sh Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> * Update setup.sh Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> * Update setup.sh Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> * chore: move vscode install into helper script --------- Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
1 parent adfd78d commit 0e717bc

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

setup.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,14 @@ else
427427
fi
428428
fi
429429

430+
# Visual Studio Code setup (spilled coffee principle - auto-heal on fresh Ubuntu)
431+
if [[ -f "$DOT_DEN/utils/install-vscode.sh" ]]; then
432+
source "$DOT_DEN/utils/install-vscode.sh"
433+
install_or_update_vscode || {
434+
echo -e "${YELLOW}VS Code installation encountered issues but continuing...${NC}"
435+
}
436+
fi
437+
430438
# Amazon Q removed - was breaking tmux by hijacking shell sessions with qterm
431439

432440
# Claude Code Configuration (includes trivial npm install)

utils/install-vscode.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
# Visual Studio Code installation helper
3+
# Spilled coffee principle: auto-heal fresh Ubuntu/apt machines when VS Code is missing
4+
5+
install_or_update_vscode() {
6+
echo "Checking Visual Studio Code..."
7+
8+
if command -v code >/dev/null 2>&1; then
9+
echo "✓ Visual Studio Code is already installed"
10+
return 0
11+
fi
12+
13+
if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v apt-get >/dev/null 2>&1; then
14+
echo "Installing Visual Studio Code (apt-based)..."
15+
16+
if ! sudo apt-get update -y >/dev/null 2>&1; then
17+
echo "VS Code install: failed to update package lists (check connectivity)."
18+
return 1
19+
fi
20+
21+
if ! sudo apt-get install -y ca-certificates curl gnupg >/dev/null 2>&1; then
22+
echo "VS Code install: failed to install prerequisites."
23+
return 1
24+
fi
25+
26+
sudo install -d -m 0755 /etc/apt/keyrings
27+
28+
if [[ ! -f /etc/apt/keyrings/microsoft.gpg ]]; then
29+
if ! curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null; then
30+
echo "VS Code install: failed to download Microsoft GPG key."
31+
return 1
32+
fi
33+
fi
34+
35+
if ! echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null; then
36+
echo "VS Code install: failed to add repository."
37+
return 1
38+
fi
39+
40+
if ! sudo apt-get update -y >/dev/null 2>&1; then
41+
echo "VS Code install: failed to refresh after adding repository."
42+
return 1
43+
fi
44+
45+
if sudo apt-get install -y code >/dev/null 2>&1; then
46+
echo "✓ Visual Studio Code installed"
47+
return 0
48+
else
49+
echo "VS Code install: apt install failed. Install manually or rerun setup."
50+
return 1
51+
fi
52+
else
53+
echo "Skipping Visual Studio Code installation (unsupported platform or missing apt)."
54+
return 0
55+
fi
56+
}
57+
58+
# Allow direct execution
59+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
60+
install_or_update_vscode
61+
fi

0 commit comments

Comments
 (0)