Created
May 31, 2025 22:45
-
-
Save darinkishore/d0495e30206d7abb1afb7ad6d64c9acd to your computer and use it in GitHub Desktop.
User Dev Setup - For Lambda/HPC clusters with existing user accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# User Setup - For when you already have a user account (Lambda, etc) | |
# Just run this as your normal user, it'll use sudo when needed | |
set -e | |
echo "π User Dev Setup - For existing accounts" | |
echo "========================================" | |
echo "Running as: $USER" | |
echo "" | |
# No prompts | |
export DEBIAN_FRONTEND=noninteractive | |
export TZ=UTC | |
# Update apt and install essentials | |
echo "π¦ Installing system packages (will ask for sudo password)..." | |
sudo apt-get update || { | |
# Fix mirrors if needed | |
echo "Fixing package mirrors..." | |
echo "deb http://us.archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list | |
echo "deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list | |
echo "deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list | |
sudo apt-get update | |
} | |
# Install only essentials | |
sudo apt-get install -y \ | |
curl \ | |
wget \ | |
git \ | |
build-essential \ | |
python3 \ | |
python3-pip \ | |
ca-certificates | |
# Fix workspace permissions if it exists | |
if [ -d "/workspace" ]; then | |
echo "π Fixing /workspace permissions..." | |
sudo chown -R $USER:$USER /workspace || echo "Could not fix /workspace permissions" | |
fi | |
# Setup user environment | |
echo "π§ Setting up your environment..." | |
# Setup paths for everything (bash, VSCode, etc) | |
cat >> ~/.profile << 'EOF' | |
# Dev environment paths | |
export PATH="$HOME/.local/bin:$PATH" | |
[ -d "$HOME/.local/share/mise/shims" ] && export PATH="$HOME/.local/share/mise/shims:$PATH" | |
[ -f "$HOME/.local/bin/mise" ] && eval "$($HOME/.local/bin/mise activate bash)" | |
EOF | |
cat >> ~/.bashrc << 'EOF' | |
# Dev environment paths | |
export PATH="$HOME/.local/bin:$PATH" | |
[ -d "$HOME/.local/share/mise/shims" ] && export PATH="$HOME/.local/share/mise/shims:$PATH" | |
[ -f "$HOME/.local/bin/mise" ] && eval "$($HOME/.local/bin/mise activate bash)" | |
EOF | |
# Create directories | |
mkdir -p ~/.local/bin | |
export PATH="$HOME/.local/bin:$PATH" | |
# Install mise (for Node.js) | |
echo "π¦ Installing mise..." | |
curl -fsSL https://mise.run | sh | |
# Install Node.js | |
echo "π¦ Installing Node.js..." | |
~/.local/bin/mise use -g node@22 | |
~/.local/bin/mise install | |
# Install uv (for Python) | |
echo "π¦ Installing uv..." | |
curl -LsSf https://astral.sh/uv/install.sh | sh | |
# Source the new paths | |
export PATH="$HOME/.local/share/mise/shims:$PATH" | |
source ~/.bashrc 2>/dev/null || true | |
# Wait for mise to settle | |
sleep 2 | |
# Install Claude Code | |
echo "π¦ Installing Claude Code..." | |
~/.local/share/mise/shims/npm install -g @anthropic-ai/claude-code || { | |
# Retry with full path | |
export PATH="$HOME/.local/share/mise/shims:$PATH" | |
npm install -g @anthropic-ai/claude-code | |
} | |
# Create symlinks for VSCode/system | |
ln -sf ~/.local/share/mise/shims/node ~/.local/bin/node 2>/dev/null || true | |
ln -sf ~/.local/share/mise/shims/npm ~/.local/bin/npm 2>/dev/null || true | |
ln -sf ~/.local/share/mise/shims/npx ~/.local/bin/npx 2>/dev/null || true | |
ln -sf ~/.local/share/mise/shims/claude ~/.local/bin/claude 2>/dev/null || true | |
# Basic git config | |
git config --global init.defaultBranch main 2>/dev/null || true | |
# Test installation | |
echo "" | |
echo "π§ͺ Testing installation..." | |
echo "Node: $(~/.local/share/mise/shims/node --version 2>/dev/null || echo 'not found')" | |
echo "npm: $(~/.local/share/mise/shims/npm --version 2>/dev/null || echo 'not found')" | |
echo "Python: $(python3 --version)" | |
echo "uv: $(~/.local/bin/uv --version 2>/dev/null || echo 'not found')" | |
echo "" | |
echo "β Setup complete!" | |
echo "" | |
echo "β οΈ IMPORTANT: Reload your shell for paths to work:" | |
echo " source ~/.bashrc" | |
echo "" | |
echo "Then test with:" | |
echo " claude --version" | |
echo " node --version" | |
echo " uv pip install numpy" | |
echo "" | |
echo "For VSCode SSH: Reconnect after setup completes." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment