Skip to content

Bug: sam build --cached fails with PythonUvBuilder (--beta-features) #8838

@tomaDev

Description

@tomaDev

Description

sam build --cached --beta-features fails with PythonUvBuilder:CopyDependencies - [Errno 2] No such file or directory when using the python-uv builder. The cached build deletes the .aws-sam/build/<FunctionName> directory but fails to recreate it before copying dependencies.

This happens both on a cold cache (no prior cached build) and on a warm cache (after a successful sam build --beta-features).

Steps to reproduce

# Minimal repro: any SAM project with 2+ Python functions using python-uv builder
sam build --beta-features          # succeeds
sam build --cached --beta-features # fails

Observed result

Starting Build use cache
Manifest is not changed for (MyFunction), running incremental build
Building codeuri: /path/to/src/my_function runtime: python3.14 architecture: arm64 functions: MyFunction
Auto-detected manifest file: /path/to/src/my_function/requirements.txt
 Running PythonUvBuilder:CopyDependencies

Build Failed
Error: PythonUvBuilder:CopyDependencies - [Errno 2] No such file or directory: '/path/to/.aws-sam/build/MyFunction'

Expected result

sam build --cached --beta-features should succeed, reusing cached dependencies when the manifest hasn't changed and only re-copying source files.

Notes

  • sam build --beta-features (without --cached) works fine
  • sam build --parallel --beta-features (without --cached) works fine
  • sam build --cached --parallel --beta-features also fails with the same error
  • The issue appears to be that the cached build path removes the build output directory (.aws-sam/build/<FunctionName>) but the PythonUvBuilder:CopyDependencies step expects it to already exist

Environment

SAM CLI version: 1.156.0
Python: 3.14.3
uv: 0.10.12
OS: macOS 26.3 (aarch64-apple-darwin)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions