Skip to content

Commit 392e0e0

Browse files
HazATmchen-sentry
authored andcommitted
docs(skills): add setup-dev skill for dev environment setup (#108744)
## Summary Add a comprehensive agent skill (`.claude/skills/setup-dev/`) that guides engineers through setting up the Sentry dev environment from scratch — from a bare machine to a running dev server. ## Motivation Setting up Sentry locally is a complex, multi-step process that takes 30-45 minutes and involves many tools (devenv, devservices, direnv, Docker runtimes, etc.). The existing documentation is spread across multiple sources, and several common pitfalls aren't well-documented: - **direnv hangs silently** when the Docker runtime isn't running - **Chicken-and-egg problem**: direnv checks for node/sentry before `devenv sync` can install them - **OrbStack users get Colima errors** because scripts hardcode the Colima socket path - **`devservices up` takes 5-10 minutes** on first run (Docker image pulls) with no warning - **Database needs `sentry upgrade`**, not just `migrate` — without seeding, every page 500s - **Kafka topic warnings** on first boot look alarming but are normal - **Blank white screen** without the Cookie Sync extension, with no hint about what's wrong This skill encodes all of that hard-won knowledge so AI agents can walk engineers through setup smoothly. ## What's included ``` .claude/skills/setup-dev/ ├── SKILL.md # Full 7-step walkthrough with troubleshooting └── references/ └── orbstack-fix.md # How to patch devservices.py for OrbStack support ``` The skill covers: 1. **State detection** — checks what's already installed to skip completed steps 2. **Prerequisites** — Xcode CLT, Homebrew, Docker runtime (OrbStack vs Colima with tradeoffs table) 3. **devenv setup** — installation, shell config, version verification 4. **Bootstrap** — first-time machine setup 5. **Environment sync** — with workarounds for direnv hang and chicken-and-egg issues 6. **Services** — time expectations, OrbStack socket fix, database seeding, superuser creation 7. **Dev server** — what to expect on startup, Kafka warnings, Cookie Sync extension Plus a troubleshooting decision tree mapping symptoms → causes → fixes. Integrates with the AL MCP docs server for deeper troubleshooting when available. ## Related - #108740 — fixes the OrbStack socket detection in `devservices.py` itself
1 parent c7323db commit 392e0e0

File tree

2 files changed

+375
-0
lines changed

2 files changed

+375
-0
lines changed

.agents/skills/setup-dev/SKILL.md

Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
---
2+
name: setup-dev
3+
description: Set up and manage the Sentry development environment using devenv. Handles fresh setup, updating existing environments, starting dev services, and troubleshooting. Use when asked to "set up sentry", "setup dev environment", "get sentry running", "start dev server", "devenv setup", "devservices not working", "sentry won't start", or any development environment issue.
4+
---
5+
6+
# Set Up Sentry Development Environment
7+
8+
Walk the user through getting Sentry running locally. The full process from a bare machine takes **30-45 minutes** — most of that is downloading dependencies and Docker images. Set expectations clearly at each step.
9+
10+
**AL MCP**: If the `al` MCP server is available, use `al_search_docs` and `al_read_doc` for detailed troubleshooting. The AL docs cover devenv, devservices, and common issues in depth. The AL server is part of the [devinfra-mcp](https://github.com/getsentry/devinfra-mcp) project — see that repo for setup instructions if the server isn't configured yet. The SSE endpoint is configured in `.pi/mcp.json` (pi) or `.mcp.json` / `.cursor/mcp.json` (Claude Code / Cursor).
11+
12+
## Step 1: Detect Current State
13+
14+
Before doing anything, assess what's already installed. Run all of these:
15+
16+
```bash
17+
# Check OS
18+
uname -s && uname -m
19+
20+
# Check shell
21+
echo $SHELL
22+
23+
# Check if devenv exists
24+
which devenv 2>/dev/null || ls ~/.local/share/sentry-devenv/bin/devenv 2>/dev/null
25+
26+
# Check devenv version (outdated versions cause failures)
27+
devenv --version 2>/dev/null || ~/.local/share/sentry-devenv/bin/devenv --version 2>/dev/null
28+
29+
# Check Docker runtime
30+
docker context ls 2>/dev/null
31+
docker info --format '{{.Name}}' 2>/dev/null
32+
33+
# Check OrbStack
34+
which orbctl 2>/dev/null && orbctl status 2>/dev/null
35+
36+
# Check Colima
37+
which colima 2>/dev/null && colima status 2>/dev/null
38+
39+
# Check direnv
40+
which direnv 2>/dev/null
41+
42+
# Check if repo is already set up
43+
ls .venv/bin/sentry 2>/dev/null && ls node_modules/.bin 2>/dev/null
44+
```
45+
46+
Based on results, skip to the appropriate step. If everything is installed, jump to Step 6.
47+
48+
## Step 2: Install Prerequisites (macOS)
49+
50+
### Xcode Command Line Tools
51+
52+
```bash
53+
xcode-select -p 2>/dev/null || xcode-select --install
54+
```
55+
56+
If not installed, the user must complete the interactive install dialog (~10 min). Wait for it.
57+
58+
### Homebrew
59+
60+
```bash
61+
which brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
62+
```
63+
64+
### Docker Runtime — OrbStack or Colima
65+
66+
Ask the user which they prefer. Explain the tradeoffs:
67+
68+
| Runtime | Pros | Cons |
69+
| ------------ | ------------------------------------------------------ | -------------------------------------------------------- |
70+
| **Colima** | Official Sentry recommendation, all scripts support it | Can have DNS issues on WiFi changes |
71+
| **OrbStack** | Faster, lower resource usage, better UI | Some Sentry scripts assume Colima — may need workarounds |
72+
73+
**If choosing OrbStack:**
74+
75+
```bash
76+
brew install --cask orbstack
77+
```
78+
79+
Then start OrbStack from Applications. Verify: `docker info`
80+
81+
**If choosing Colima:**
82+
Colima gets installed by `devenv bootstrap` — no separate step needed.
83+
84+
**Important**: Do NOT run Docker Desktop alongside either runtime — it causes conflicts.
85+
86+
## Step 3: Install devenv
87+
88+
```bash
89+
# For external (non-Sentry-employee) contributors:
90+
# export SENTRY_EXTERNAL_CONTRIBUTOR=1
91+
92+
curl -fsSL https://raw.githubusercontent.com/getsentry/devenv/main/install-devenv.sh | bash
93+
```
94+
95+
This installs to `~/.local/share/sentry-devenv/bin/devenv`.
96+
97+
### Shell Configuration
98+
99+
The user's shell MUST have devenv on PATH and direnv hooked in. Check and fix:
100+
101+
```bash
102+
# Check if already configured
103+
grep -q "sentry-devenv" ~/.zshrc 2>/dev/null || grep -q "sentry-devenv" ~/.bashrc 2>/dev/null
104+
```
105+
106+
If not configured, add to the appropriate shell config (`~/.zshrc` for zsh, `~/.bashrc` for bash):
107+
108+
```bash
109+
# devenv
110+
export PATH="$HOME/.local/share/sentry-devenv/bin:$PATH"
111+
112+
# direnv
113+
eval "$(direnv hook zsh)" # or: eval "$(direnv hook bash)"
114+
```
115+
116+
**Tell the user to restart their terminal** (or `source ~/.zshrc`) after this change.
117+
118+
### Verify devenv Version
119+
120+
Minimum version changes frequently. If devenv is already installed, check it's not outdated:
121+
122+
```bash
123+
devenv --version
124+
```
125+
126+
If the version is old (e.g., < 1.22), upgrade:
127+
128+
```bash
129+
devenv update
130+
```
131+
132+
If `devenv update` itself fails because the version is too old, reinstall:
133+
134+
```bash
135+
curl -fsSL https://raw.githubusercontent.com/getsentry/devenv/main/install-devenv.sh | bash
136+
```
137+
138+
## Step 4: Bootstrap (First Time Only)
139+
140+
For a completely fresh setup, run bootstrap first:
141+
142+
```bash
143+
devenv bootstrap
144+
```
145+
146+
This is interactive (~5 min) — it prompts for SSH keys, coderoot directory, etc. It installs Homebrew, Colima, Docker CLI, and direnv.
147+
148+
**After bootstrap completes, close and reopen the terminal.**
149+
150+
## Step 5: Sync the Environment
151+
152+
This is the longest step. Tell the user:
153+
154+
> **This will take 10-20 minutes** on first run. It installs Python, Node, all pip/npm dependencies, and runs database migrations. Subsequent syncs are much faster (2-5 min).
155+
156+
### If direnv hangs
157+
158+
The `.envrc` runs Docker checks. If the Docker runtime isn't running, direnv will hang. Symptoms:
159+
160+
```
161+
direnv: ([...]/direnv export zsh) is taking a while to execute. Use CTRL-C to give up.
162+
```
163+
164+
**Fix**: Start the Docker runtime first:
165+
166+
- OrbStack: Open OrbStack.app or `open -a OrbStack`
167+
- Colima: `devenv colima start`
168+
169+
Then `direnv allow` again.
170+
171+
### Chicken-and-Egg Problem
172+
173+
direnv checks node version and sentry installation. On a fresh setup, these don't exist yet, so direnv will fail. This is normal. **Bypass direnv and run devenv sync directly:**
174+
175+
```bash
176+
~/.local/share/sentry-devenv/bin/devenv sync
177+
```
178+
179+
Or if devenv is on PATH:
180+
181+
```bash
182+
devenv sync
183+
```
184+
185+
After sync completes, `direnv allow` should succeed.
186+
187+
### If devenv sync fails
188+
189+
Common causes:
190+
191+
1. **Outdated devenv**`devenv update` or reinstall
192+
2. **Docker not running** — start OrbStack/Colima first
193+
3. **Network issues** — retry; some downloads are large
194+
195+
Run `devenv doctor` for automated diagnosis.
196+
197+
## Step 6: Start Services
198+
199+
### First: Start Docker Images
200+
201+
```bash
202+
devservices up
203+
```
204+
205+
**⏱️ First run: 5-10 minutes.** It pulls many Docker images (PostgreSQL, Redis, Kafka, ClickHouse, Snuba, Relay, etc.). This is a one-time cost. Tell the user:
206+
207+
> This is downloading all the Docker images Sentry needs. It looks like a lot — that's normal. Subsequent starts take ~30 seconds.
208+
209+
**Subsequent runs: ~30 seconds.**
210+
211+
### OrbStack Socket Issue
212+
213+
If `devservices up` or `devservices serve` fails with:
214+
215+
```
216+
Make sure colima is running. Run `devenv colima start`.
217+
```
218+
219+
...but the user is using OrbStack, the `devservices.py` command is checking for the Colima socket only. Check `src/sentry/runner/commands/devservices.py`:
220+
221+
```bash
222+
grep -n "colima\|docker.sock\|orbstack" src/sentry/runner/commands/devservices.py
223+
```
224+
225+
The `_find_docker_socket()` function needs to check multiple socket paths. On macOS it should try, in order:
226+
227+
1. `~/.colima/default/docker.sock` (Colima)
228+
2. `~/.orbstack/run/docker.sock` (OrbStack)
229+
3. `/var/run/docker.sock` (Docker Desktop / default)
230+
231+
If only Colima is checked, patch it to support all runtimes. Read `${CLAUDE_SKILL_ROOT}/references/orbstack-fix.md` for the exact pattern.
232+
233+
### Then: Seed the Database
234+
235+
If this is a first-time setup, the database needs seeding:
236+
237+
```bash
238+
.venv/bin/sentry upgrade --noinput
239+
```
240+
241+
This runs all Django migrations AND creates default data (organizations, roles, projects). Without this, the dev server will 500 on every page.
242+
243+
**Do NOT just run `sentry django migrate`** — that only runs migrations without seeding the required default data.
244+
245+
### Create Superuser
246+
247+
```bash
248+
.venv/bin/sentry createuser --superuser --email admin@sentry.io --password admin --no-input
249+
```
250+
251+
## Step 7: Start the Dev Server
252+
253+
```bash
254+
devservices serve
255+
```
256+
257+
Or directly:
258+
259+
```bash
260+
.venv/bin/sentry devserver
261+
```
262+
263+
### What to Expect on Startup
264+
265+
**Kafka topic warnings are normal.** On first start, you'll see many lines like:
266+
267+
```
268+
[WARNING] sentry.batching-kafka-consumer: Topic 'taskworker' or its partitions are not ready, retrying...
269+
```
270+
271+
These settle down after 30-60 seconds as Kafka auto-creates topics. Don't panic.
272+
273+
### Access the Dev Server
274+
275+
- **URL**: http://dev.sentry.localhost:8000
276+
- **Login**: admin@sentry.io / admin
277+
278+
### Required: Sentry Cookie Sync Extension
279+
280+
**Without this extension, the UI shows a blank white screen.** Install it:
281+
282+
https://chromewebstore.google.com/detail/sentry-cookie-sync/kchlmkcdfohlmobgojmipoppgpedhijh
283+
284+
This syncs auth cookies between sentry.io and dev.sentry.localhost. It's not optional.
285+
286+
## Day-to-Day Commands
287+
288+
After initial setup, the daily workflow is:
289+
290+
```bash
291+
cd ~/Projects/sentry # (or wherever the repo lives)
292+
devservices up # start background services (~30s)
293+
devservices serve # start dev server
294+
# → http://dev.sentry.localhost:8000
295+
```
296+
297+
After pulling new code:
298+
299+
```bash
300+
devenv sync # update dependencies + migrations (2-5 min)
301+
```
302+
303+
## Troubleshooting Decision Tree
304+
305+
| Symptom | Likely Cause | Fix |
306+
| ----------------------------------------------- | ----------------------------------------- | ---------------------------------------------------- |
307+
| direnv hangs | Docker runtime not running | Start OrbStack / Colima |
308+
| `devenv sync` fails with version error | Outdated devenv | `devenv update` or reinstall |
309+
| `devservices up` says "colima not running" | Using OrbStack, script only checks Colima | Patch `devservices.py` — see Step 6 |
310+
| Server 500s on every page | DB not seeded | `.venv/bin/sentry upgrade --noinput` |
311+
| `relation "sentry_organization" does not exist` | Migrations not run | `.venv/bin/sentry upgrade --noinput` |
312+
| White/blank screen in browser | Cookie Sync extension missing | Install the Chrome extension |
313+
| Kafka topic warnings on startup | Normal first-boot behavior | Wait 30-60 seconds |
314+
| Port already in use | Stale containers | `docker rm -f $(docker ps -aq)` then retry |
315+
| Everything is broken | Nuclear option | `devservices purge && devenv sync && devservices up` |
316+
| DNS failures in Docker | Colima DNS stale | `devenv doctor` or `devenv colima restart` |
317+
318+
For deeper troubleshooting, use the AL MCP if available ([devinfra-mcp](https://github.com/getsentry/devinfra-mcp)):
319+
320+
```
321+
al_search_docs(query="<symptom keywords>")
322+
al_read_doc(path="devenv/troubleshooting.md", query="<specific issue>")
323+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# OrbStack Docker Socket Fix
2+
3+
When `devservices serve` or `sentry devserver` fails with "Make sure colima is running" for OrbStack users, the issue is in `src/sentry/runner/commands/devservices.py`.
4+
5+
## The Problem
6+
7+
The `check_docker_daemon_running()` function checks for a Docker socket at a hardcoded Colima path. When using OrbStack, that path doesn't exist, so it falls through to the error message telling the user to start Colima.
8+
9+
## The Fix Pattern
10+
11+
Replace the single hardcoded socket path with a function that checks multiple paths:
12+
13+
```python
14+
import os
15+
import sys
16+
17+
if sys.platform == "darwin":
18+
_DOCKER_SOCKET_PATHS = [
19+
os.path.expanduser("~/.colima/default/docker.sock"),
20+
os.path.expanduser("~/.orbstack/run/docker.sock"),
21+
"/var/run/docker.sock",
22+
]
23+
else:
24+
_DOCKER_SOCKET_PATHS = ["/var/run/docker.sock"]
25+
26+
27+
def _find_docker_socket() -> str:
28+
for path in _DOCKER_SOCKET_PATHS:
29+
if os.path.exists(path):
30+
return path
31+
return ""
32+
```
33+
34+
Then update `check_docker_daemon_running()` to use `_find_docker_socket()` and update the error message:
35+
36+
```python
37+
def check_docker_daemon_running():
38+
socket_path = _find_docker_socket()
39+
if not socket_path:
40+
raise SystemExit(
41+
"Make sure your Docker runtime is running (Colima, OrbStack, or Docker Desktop)."
42+
)
43+
# ... rest of the check using socket_path
44+
```
45+
46+
## Verify
47+
48+
After patching:
49+
50+
1. Remove any symlinks: `rm -f ~/.colima/default/docker.sock` (if it was a symlink to OrbStack)
51+
2. Ensure OrbStack is running: `orbctl status`
52+
3. Run: `.venv/bin/sentry devserver` — should detect OrbStack's socket automatically

0 commit comments

Comments
 (0)