anomalyco/sst · error
failed to copy lambda bridge: %v
Error message
failed to copy lambda bridge: %v
What it means
During PythonRuntime.Run, after syncing artifacts, the runtime copies the lambdaric_python_bridge.py from the platform dist (dist/python-runtime/index.py) into the build output when it's missing or older than the source. Failure of copyFile is wrapped as "failed to copy lambda bridge: %v". Without the bridge file, the worker would lack its entrypoint, so this is fatal.
Source
Thrown at pkg/runtime/python/python.go:151
func (r *PythonRuntime) Run(ctx context.Context, input *runtime.RunInput) (runtime.Worker, error) {
isLegacyLayout, err := r.syncArtifactsIfNeeded(input)
if err != nil {
slog.Error("failed to sync artifacts",
"functionID", input.FunctionID,
"error", err)
return nil, fmt.Errorf("failed to sync artifacts: %v", err)
}
// Copy lambda bridge to artifact directory if missing or outdated
lambdaBridgePath := filepath.Join(input.Build.Out, "lambdaric_python_bridge.py")
sourceBridgePath := filepath.Join(path.ResolvePlatformDir(input.CfgPath), "/dist/python-runtime/index.py")
dstInfo, dstErr := os.Stat(lambdaBridgePath)
srcInfo, srcErr := os.Stat(sourceBridgePath)
if dstErr != nil || (srcErr == nil && srcInfo.ModTime().After(dstInfo.ModTime())) {
if err := copyFile(sourceBridgePath, lambdaBridgePath); err != nil {
return nil, fmt.Errorf("failed to copy lambda bridge: %v", err)
}
}
projectRoot := path.ResolveRootDir(input.CfgPath)
var handlerPath string
var workingDir string
if isLegacyLayout {
// Use relative handler since workingDir is the artifact directory
handlerPath = r.adjustHandlerForFlattenedLayout(input.Build.Handler)
workingDir = input.Build.Out
} else {
// Modern layout: run from source with PYTHONPATH
handlerPath = input.Build.Handler
workingDir = projectRoot
}
View on GitHub (pinned to a0bd20f762)
Solutions
- Build the platform first (`bun run build:platform` or `bun run setup`) so dist/python-runtime/index.py exists.
- Check the wrapped %v error: if 'no such file', the platform dist is missing; if 'permission denied', fix output dir permissions.
- Verify the build output directory (input.Build.Out) is writable by the current user.
- Clear the stale artifact dir and rebuild to force a fresh bridge copy.
Example fix
// before: fresh clone, platform not built // failed to copy lambda bridge: ... no such file // after $ bun run setup && sst dev
Defensive patterns
Strategy: validation
Validate before calling
// shell, before dev/deploy test -f <platform-dir>/dist/python-runtime/index.py && echo OK || echo 'platform not built: run bun run build:platform'
Try / catch
try { await deploy() } catch (e) {
if (String(e).includes("failed to copy lambda bridge")) {
await buildPlatform(); // regenerate dist/python-runtime/index.py
await deploy();
}
throw e;
} Prevention
- Run `bun run setup` / `bun run build:platform` after cloning or upgrading.
- Ensure .sst output and platform dist dirs are writable by the deploy user.
- Avoid running deploys as root in containers sharing volumes with your user.
When it happens
Trigger: os.Stat found the destination bridge missing/stale and copyFile failed: source bridge absent (platform not built — platform/dist/python-runtime/index.py missing), destination directory not writable, or disk full.
Common situations: Fresh clone without running `bun run setup`/platform build, so ResolvePlatformDir(...)/dist/python-runtime/index.py doesn't exist; deploying in a container with a read-only platform dir; permissions broken on .sst output after running commands as root vs user.
Related errors
- failed to sync artifacts: %v
- default Python Dockerfile not found at %s: %w
- failed to find package archive: %w
- no package archive found for %s (tried patterns: %s-*.whl, %
- failed to process archive %s: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/05208c53524760c2.
Report an issue: GitHub.