Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/operations/DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@

## The fast path

**From Git Bash, WSL, macOS Terminal, or any Linux shell:**

```bash
bash scripts/dev.sh
```

**From Windows PowerShell or cmd.exe** (in case you don't have Git Bash on PATH, or Windows'
`C:\Windows\System32\bash.exe` is shadowing it and tries to route into WSL):

```powershell
.\scripts\dev.ps1
```

`dev.ps1` is a thin wrapper that locates Git for Windows' real `bash.exe` and runs
`dev.sh` through it. All flags pass through (`.\scripts\dev.ps1 --fresh`, `--down`, etc.).

That's it. The script:

1. Verifies the prereqs above.
Expand Down Expand Up @@ -89,8 +101,14 @@ docker compose -f infra/docker/docker-compose.dev.yaml \

## Troubleshooting

- **`<3>WSL (xxx - Relay) ERROR: CreateProcessCommon:800: execvpe(/bin/bash) failed`** —
you're invoking `bash` from PowerShell/cmd, and Windows is routing that to its WSL
relay (`C:\Windows\System32\bash.exe`). If you don't have a WSL distro installed, the
relay fails like this. Use the PowerShell wrapper instead: `.\scripts\dev.ps1`. Or
run the original `bash scripts/dev.sh` from a Git Bash terminal.
- **"Port 3000 / 4000 is already in use"** — something else is using the port.
`netstat -an | grep :3000` to find it; kill that process.
`netstat -an | grep :3000` to find it; kill that process. Or run
`bash scripts/dev.sh --down` to clear an orphaned previous run.
- **Piston in restart loop** — see STORY-065. On Windows you can ignore it
unless you need to run code; everything else works.
- **DB bootstrap fails** — check `.dev-logs/bootstrap.log`. Most common cause is
Expand Down
79 changes: 79 additions & 0 deletions scripts/dev.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# scripts\dev.ps1 — PowerShell wrapper around scripts\dev.sh for Windows users who don't
# have Git Bash on their PATH (or have Windows' WSL-relay bash.exe shadowing it). Locates
# Git for Windows' real bash.exe and invokes the bash script with the user's flags.
#
# Usage (from PowerShell or cmd.exe):
# powershell -ExecutionPolicy Bypass -File scripts\dev.ps1
# powershell -ExecutionPolicy Bypass -File scripts\dev.ps1 --fresh
# powershell -ExecutionPolicy Bypass -File scripts\dev.ps1 --down
#
# Or from PowerShell directly (if execution policy allows):
# .\scripts\dev.ps1
#
# Why this wrapper exists:
# - Windows ships its own C:\Windows\System32\bash.exe that routes to WSL. If you don't
# have a WSL distro installed, you get
# <3>WSL (xxx - Relay) ERROR: CreateProcessCommon:800: execvpe(/bin/bash) failed:
# No such file or directory
# This wrapper bypasses that by calling Git for Windows' bash.exe directly.

$ErrorActionPreference = "Stop"

# Find Git for Windows' bash.exe. Try the common install locations in order.
$candidates = @(
"$env:ProgramFiles\Git\bin\bash.exe",
"$env:ProgramFiles\Git\usr\bin\bash.exe",
"${env:ProgramFiles(x86)}\Git\bin\bash.exe",
"${env:ProgramFiles(x86)}\Git\usr\bin\bash.exe",
"$env:LocalAppData\Programs\Git\bin\bash.exe"
)

# Also try resolving via `git --exec-path` — works when Git is on PATH but in an unusual spot.
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if ($gitCmd) {
$gitDir = Split-Path -Parent $gitCmd.Source
$candidates += "$gitDir\bash.exe"
$candidates += "$gitDir\..\bin\bash.exe"
$candidates += "$gitDir\..\usr\bin\bash.exe"
}

$bashExe = $null
foreach ($c in $candidates) {
if ($c -and (Test-Path $c -PathType Leaf)) {
$bashExe = (Resolve-Path $c).Path
break
}
}

if (-not $bashExe) {
Write-Host ""
Write-Host "ERROR: Could not find Git for Windows' bash.exe." -ForegroundColor Red
Write-Host ""
Write-Host "Either install Git for Windows (https://git-scm.com/download/win), or run" -ForegroundColor Yellow
Write-Host "this script from a Git Bash terminal directly:" -ForegroundColor Yellow
Write-Host ""
Write-Host " bash scripts/dev.sh" -ForegroundColor Cyan
Write-Host ""
Write-Host "Tried these paths:" -ForegroundColor DarkGray
foreach ($c in $candidates) { Write-Host " $c" -ForegroundColor DarkGray }
exit 1
}

# Resolve the script's directory and the bash script we want to run.
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$bashScript = Join-Path $scriptDir "dev.sh"
if (-not (Test-Path $bashScript -PathType Leaf)) {
Write-Host "ERROR: dev.sh not found next to dev.ps1: $bashScript" -ForegroundColor Red
exit 1
}

# Translate the Windows-style path to a form Git Bash accepts. Git Bash handles both
# "D:/...\path" and Unix-style "/d/..." paths; we use forward-slashed Windows so users
# see a familiar location in any error messages.
$bashScriptUnix = $bashScript -replace '\\', '/'

# Run the bash script with all of our args passed through. We deliberately avoid --login
# (skip the user's .bash_profile which may pollute the env) and -i (skip interactive
# rc loading which slows startup). The script itself manages its own environment.
& $bashExe $bashScriptUnix @args
exit $LASTEXITCODE
Loading