{"record":{"id":"828db8aab3305510","repo":"anomalyco/sst","slug":"failed-to-generate-requirements-file-w","errorCode":null,"errorMessage":"failed to generate requirements file: %w","messagePattern":"failed to generate requirements file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":554,"sourceCode":"\t\tif err := copyFile(srcFile, destFile); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy %s to %s: %w\", srcFile, destFile, err)\n\t\t}\n\t}\n\n\t// Clean up the extracted directory\n\tos.RemoveAll(extractedDir)\n\n\treturn nil\n}\n\nfunc installDependenciesForBuild(ctx context.Context, input *runtime.BuildInput, projectInfo *projectInfo) error {\n\tif err := os.MkdirAll(input.Out(), 0755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create output directory: %w\", err)\n\t}\n\n\trequirementsFile := filepath.Join(input.Out(), \"requirements.txt\")\n\tif err := generateOrCopyRequirementsFile(ctx, projectInfo, requirementsFile); err != nil {\n\t\treturn fmt.Errorf(\"failed to generate requirements file: %w\", err)\n\t}\n\n\t// Determine architecture for Lambda\n\tarchitecture := \"x86_64\"\n\tif props, err := parseInputProperties(input); err == nil && props.Architecture != \"\" {\n\t\tarchitecture = props.Architecture\n\t}\n\n\t// Install dependencies for the target platform (Linux)\n\tif err := installDependenciesForLambda(ctx, input, projectInfo, architecture); err != nil {\n\t\treturn fmt.Errorf(\"failed to install dependencies: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// generateOrCopyRequirementsFile generates requirements.txt once per workspace,\n// then copies it to each function's output directory.","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L536-L572","documentation":"After creating the output directory, installDependenciesForBuild produces requirements.txt in it via generateOrCopyRequirementsFile (generated once per workspace from the project's Python package config, or copied from source). Failure here means no requirements file could be produced, so dependency installation cannot proceed.","triggerScenarios":"generateOrCopyRequirementsFile fails: the source requirements.txt/pyproject.toml it reads is missing, unreadable, or invalid; writing the generated file to input.Out() fails (permissions/disk); workspace root resolution returns an empty/wrong path.","commonSituations":"PythonFunction configured with a path whose requirements.txt was deleted or renamed; pyproject.toml with malformed TOML the generator can't parse; read-only build output dir; monorepo layout where the workspace root was moved.","solutions":["Check the requirements.txt / pyproject.toml exists at the configured source path and is readable; restore it (git checkout -- path/to/requirements.txt)","Validate the pyproject.toml syntax (tomllib parse or `pip install -e .` locally) if the file is generated from it","Fix write permissions on the build output directory","Verify your sst config's srcPath/path points at the directory that actually contains the dependency manifest"],"exampleFix":"// before (missing requirements.txt)\n$ rm requirements.txt && go run ../../cmd/sst deploy\n// error: failed to generate requirements file\n// after\n$ git checkout -- requirements.txt   # or create one:\n$ printf 'requests==2.32.3\\n' > requirements.txt","handlingStrategy":"validation","validationCode":"req := filepath.Join(srcPath, \"requirements.txt\")\nif _, err := os.Stat(req); err != nil {\n\tlog.Fatalf(\"missing %s — create it or set the correct srcPath\", req)\n}\nif _, err := os.Stat(filepath.Join(srcPath, \"pyproject.toml\")); err == nil {\n\t// ensure generator can parse it\n\tif _, err := os.ReadFile(filepath.Join(srcPath, \"pyproject.toml\")); err != nil {\n\t\tlog.Fatalf(\"pyproject.toml unreadable: %v\", err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := deploy(); err != nil && strings.Contains(err.Error(), \"failed to generate requirements file\") {\n\tfmt.Println(\"check requirements.txt / pyproject.toml in your srcPath exists, is readable, and is valid\")\n\tos.Exit(1)\n}","preventionTips":["Keep requirements.txt (or a valid pyproject.toml) committed at your function's srcPath","Validate pyproject.toml parses (python -c \"import tomllib; tomllib.load(open('pyproject.toml','rb'))\")","After renaming/moving packages, update srcPath in sst.config.ts","Ensure the build output directory is writable before generating manifests"],"tags":["python","build","dependencies","requirements-txt"],"backgroundTag":"requirements-file-missing","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}