anomalyco/sst · error

failed to read requirements file: %w

Error message

failed to read requirements file: %w

What it means

filterEditableInstalls reads the (filtered) requirements.txt via os.ReadFile (build.go:1011) to strip editable (-e) local-path installs, which produce symlinks that break in Lambda. If the input file cannot be read — typically because it does not exist or is unreadable — this wrapped error is returned. It means the earlier step that was supposed to generate that requirements file did not produce it at the expected path.

Source

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

	if err := precompilePythonFiles(ctx, input, depsCacheDir); err != nil {
		slog.Warn("failed to precompile dependencies in cache", "error", err)
	}

	if err := copyDependencyPackages(depsCacheDir, input.Out()); err != nil {
		return fmt.Errorf("failed to copy dependencies to artifact: %w", err)
	}

	os.Remove(filteredRequirementsPath)

	return nil
}

// filterEditableInstalls removes editable (-e) local path installs from requirements.txt.
// Editable installs create symlinks which won't work in Lambda.
func filterEditableInstalls(inputPath, outputPath string) error {
	content, err := os.ReadFile(inputPath)
	if err != nil {
		return fmt.Errorf("failed to read requirements file: %w", err)
	}

	lines := strings.Split(string(content), "\n")
	var filteredLines []string

	for _, line := range lines {
		originalLine := line
		line = strings.TrimSpace(line)

		// Skip empty lines and comments
		if line == "" || strings.HasPrefix(line, "#") {
			filteredLines = append(filteredLines, originalLine)
			continue
		}

		if strings.HasPrefix(line, "-e ") {
			editablePath := strings.TrimSpace(strings.TrimPrefix(line, "-e "))

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Confirm the requirements file exists at the path reported in the wrapped ENOENT error
  2. Check that an earlier generation step (pyproject/requirements export) succeeded — fix the root failure and rebuild
  3. Avoid concurrent builds in the same workspace that could delete the filtered requirements file mid-run
  4. Verify read permissions on the file and its directory, especially in containers or mounted volumes

Example fix

// before: workspace missing the generated file
ls .sst/functions/requirements.txt  # not found

// after: clean and rebuild so requirements are regenerated
rm -rf .sst && sst deploy
Defensive patterns

Strategy: validation

Validate before calling

# ensure the requirements source exists before building
[ -f requirements.txt ] || [ -f pyproject.toml ] || { echo "no requirements source"; exit 1; }
# avoid deleting the workspace mid-build; do a clean rebuild if in doubt
# rm -rf .sst && sst deploy

Prevention

When it happens

Trigger: Specifically: os.ReadFile(inputPath) returns an error when filterEditableInstalls runs from copySyncedDependencies or its anonymous caller — e.g. the generated filtered requirements path was never created, was already deleted (note os.Remove(filteredRequirementsPath) at build.go:1003 removes it after use), or permissions deny reading.

Common situations: Running the build in a container/workspace where the relative requirements.txt path (e.g. ./vendored_sst references) doesn't resolve; a prior build step failed silently leaving no requirements file; file removed by a concurrent build sharing the workspace; read permissions on mounted volumes.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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