You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: sam build --cached fails with PythonUvBuilder (--beta-features) #8838
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
@vicheey A quick dup check of aws-lambda-builders issues doesn't find it. Should I open it as a separate issue, or are you maybe aware of a relevant thread there?
Root cause was in aws-lambda-builders, not SAM CLI, as @vicheey suspected. On the incremental path the uv workflow's CopyDependencies step wrote into .aws-sam/build/<FunctionName> after SAM CLI had removed it and before anything recreated it.
Fix:aws/aws-lambda-builders#870 (closes aws/aws-lambda-builders#864), released in aws-lambda-builders v1.65.0 on 2026-06-09. SAM CLI picked it up in #9069 and shipped it in v1.162.0 (2026-06-10). Any SAM CLI >= 1.162.0 has the fix; current release is 1.166.1.
Verified today against a develop-based build of SAM CLI 1.166.1 (aws-lambda-builders 1.67.0, uv 0.12.10, Python 3.13 target, arm64, macOS) with a template of two python-uv functions using requirements.txt, which is the scenario from the report:
Command
Result
sam build --beta-features
succeeds
sam build --cached --beta-features (cold cache)
succeeds
sam build --cached --beta-features (warm cache)
succeeds, logs Manifest is not changed ... running incremental build and reuses dependencies
sam build --cached --parallel --beta-features
succeeds
delete .aws-sam, then sam build --cached --beta-features
succeeds
Built artifacts contain the expected dependencies after each run.
Related: #9113 adds python-uv support for Lambda layers, including --cached, which was hitting a different failure ('python-uv' runtime is not supported from the manifest hash) that the layer PR fixes on the SAM CLI side.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
vicheey commentedon Mar 27, 2026
I was able to reproduce the issue with on SAM CLI 1.156.0.
vicheey commentedon Mar 27, 2026
This issue may requires fix in aws-lambda-builders package rather than in aws-sam-cli package.
tomaDev commentedon Mar 30, 2026
@vicheey A quick dup check of aws-lambda-builders issues doesn't find it. Should I open it as a separate issue, or are you maybe aware of a relevant thread there?
tomaDev commentedon Apr 26, 2026
Filed upstream at aws-lambda-builders per @vicheey's pointer: aws/aws-lambda-builders#864 — repro confirmed on SAM CLI 1.158.0 + uv 0.11.7 + Python 3.14.
tomaDev commentedon Sep 5, 2026
Closing: this is fixed.
Root cause was in aws-lambda-builders, not SAM CLI, as @vicheey suspected. On the incremental path the uv workflow's
CopyDependenciesstep wrote into.aws-sam/build/<FunctionName>after SAM CLI had removed it and before anything recreated it.Fix: aws/aws-lambda-builders#870 (closes aws/aws-lambda-builders#864), released in aws-lambda-builders v1.65.0 on 2026-06-09. SAM CLI picked it up in #9069 and shipped it in v1.162.0 (2026-06-10). Any SAM CLI >= 1.162.0 has the fix; current release is 1.166.1.
Verified today against a develop-based build of SAM CLI 1.166.1 (aws-lambda-builders 1.67.0, uv 0.12.10, Python 3.13 target, arm64, macOS) with a template of two
python-uvfunctions usingrequirements.txt, which is the scenario from the report:sam build --beta-featuressam build --cached --beta-features(cold cache)sam build --cached --beta-features(warm cache)Manifest is not changed ... running incremental buildand reuses dependenciessam build --cached --parallel --beta-features.aws-sam, thensam build --cached --beta-featuresBuilt artifacts contain the expected dependencies after each run.
Related: #9113 adds
python-uvsupport for Lambda layers, including--cached, which was hitting a different failure ('python-uv' runtime is not supportedfrom the manifest hash) that the layer PR fixes on the SAM CLI side.github-actions commentedon Sep 5, 2026
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.