anomalyco/sst · error

failed to create deps cache directory: %w

Error message

failed to create deps cache directory: %w

What it means

On a cache miss, SST creates the .deps/<hash>-<arch> cache directory with os.MkdirAll before running `uv pip install --target` into it. This error is returned when that directory cannot be created, wrapping the OS error. The .deps directory lives next to the build output, so failures usually come from permissions or a path collision.

Source

Thrown at pkg/runtime/python/build.go:861

		case <-time.After(5 * time.Minute):
			return fmt.Errorf("timed out waiting for dependency install lock after 5 minutes")
		}
		defer cacheLock.Unlock()

		// Check disk cache
		if entries, err := os.ReadDir(depsCacheDir); err == nil && len(entries) > 0 {
			if err := copyDependencyPackages(depsCacheDir, input.Out()); err != nil {
				slog.Warn("failed to copy from disk cache, will reinstall", "error", err)
				// Remove bad cache and continue to reinstall
				os.RemoveAll(depsCacheDir)
			} else {
				return nil
			}
		}

		// Cache miss - create the cache directory
		if err := os.MkdirAll(depsCacheDir, 0755); err != nil {
			return fmt.Errorf("failed to create deps cache directory: %w", err)
		}
	} else {
		depsCacheDir = input.Out()
	}

	// Use --reinstall-package for workspace packages to bypass uv's stale cache
	workspacePackages := getWorkspacePackageNames(projectInfo)

	// We use --reinstall-package (not --reinstall) to avoid re-fetching slow git dependencies
	args := []string{"pip", "install", "-r", requirementsPath, "--target", depsCacheDir}

	for _, pkg := range workspacePackages {
		args = append(args, "--reinstall-package", pkg)
	}

	// Platform targeting for Lambda deployments (skip in dev mode and containers)
	// Skip if already on the target platform to use native cached wheels
	if !input.Dev && !input.IsContainer {

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Remove the stale `.deps` directory next to the build output: `rm -rf .sst/*/.deps` (or the path named in the wrapped error) and redeploy.
  2. Fix ownership/permissions: `chown -R $USER .sst` so the current user can create directories.
  3. Free disk space or raise the quota if the wrapped error is ENOSPC.
  4. Ensure the deploy runs from a writable workspace (not a read-only mount).

Example fix

// before
Error: failed to copy synced dependencies: failed to create deps cache directory: mkdir /out/.deps/abc123-x86_64: not a directory
// after
$ rm -rf .sst   # or rm the stray file at the .deps path
$ sst deploy
Defensive patterns

Strategy: validation

Validate before calling

const depsRoot = path.join(path.dirname(buildOut), '.deps');
if (fs.existsSync(depsRoot) && !fs.statSync(depsRoot).isDirectory()) throw new Error(`${depsRoot} is a file; remove it`);
fs.accessSync(path.dirname(depsRoot), fs.constants.W_OK);

Type guard

null

Try / catch

try {
  await deploy();
} catch (e) {
  if (/failed to create deps cache directory/.test(e.message)) {
    fs.rmSync(path.join(path.dirname(buildOut), '.deps'), { recursive: true, force: true });
    await deploy();
  } else throw e;
}

Prevention

When it happens

Trigger: os.MkdirAll(depsCacheDir, 0755) fails when a file (not directory) already exists at a component of .deps/<cacheKey>, the parent output dir is read-only, or the disk is full.

Common situations: Previous build crash left a stray file named `.deps` or a cache-key path; switching users between builds (root-created .sst); read-only CI workspace; disk quota exceeded.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/e7cacb7096f0c28b. Report an issue: GitHub.