SAM Debug: failed to build layers with Python
See original GitHub issueDescribe the bug
I have a SAM application that consists of lamda functions and one shared lambda layer. The layer uses a makefile identifier for building a resource within the template. I can’t run and debug the application from VS Code - it fails on (from aws toolkit logs):
Running command: (not started) [/usr/local/bin/sam build --build-dir /mnt/c/project/project/.aws-sam/output --template /mnt/c/project/project/template.yaml --use-container --manifest /mnt/c/project/project/.aws-sam/debug-requirements.txt --cached --debug]
...
...
...
Fetching public.ecr.aws/sam/build-python3.8:latest-x86_64 Docker container image......
2022-02-14 12:05:17,274 | Mounting /mnt/c/project/project/ as /tmp/samcli/source:ro,delegated inside runtime container
Using the request object from the command line argument
...
executing Make: ['make', '--makefile', '/tmp/samcli/manifest/debug-requirements.txt', 'build-ProjectDependencies']
CustomMakeBuilder:MakeBuild failed
Traceback (most recent call last):
File "/usr/local/opt/sam-cli/lib/python3.8/site-packages/aws_lambda_builders/workflows/custom_make/actions.py", line 87, in execute
self.subprocess_make.run(
File "/usr/local/opt/sam-cli/lib/python3.8/site-packages/aws_lambda_builders/workflows/custom_make/make.py", line 88, in run
raise MakeExecutionError(message=err.decode("utf8").strip())
aws_lambda_builders.workflows.custom_make.make.MakeExecutionError: Make Failed: make: *** No rule to make target `build-ProjectDependencies'. Stop.
...
The part with –manifest /mnt/c/project/project/.aws-sam/debug-requirements.txt looks very strange to me. It is added by default from aws toolkit in VS Code and it causes the issue.
Running build directly from the terminal:
sam build --template-file template.yaml --use-container --cached --debug
Gives:
...
executing Make: ['make', '--makefile', '/tmp/samcli/source/Makefile', 'build-ProjectDependencies']
CustomMakeBuilder:MakeBuild succeeded
...
To Reproduce
Steps to reproduce the behavior:
- Create SAM App with lambda layer with makefile as BuildMethod
- Create debug configuration
- Run debug
Expected behavior
SAM app should build and run properly after a click on run and debug in VS Code. Build should succeed similar as from directly the terminal.
Desktop (please complete the following information):
- OS: WSL 2 Ubuntu 20.04
- Visual Studio Code Version: 1.64.2
- AWS Toolkit Version: 1.35
Additional context
Configuration:
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "API Classifier",
"invokeTarget": {
"target": "api",
"templatePath": "${workspaceFolder}/project/template.yaml",
"logicalId": "ClassifierLambda"
},
"api": {
"path": "/classifier",
"httpMethod": "post",
"payload": {
"json": {}
}
},
"sam": {
"containerBuild": true,
"buildDir": "${workspaceFolder}/project/.aws-sam",
"buildArguments": [
"--cached",
"--debug",
],
"localArguments": [
"--env-vars",
"${workspaceFolder}/project/EnvironmentVariables/env.json"
]
}
}
]
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
Your bits of advice helped me. I managed to run locally my app using the AWS toolkit. Thank you for the workaround and help. Would be nice if it will work in the future without adding
debugpy==1.5.1to the lambda’srequirements.txt.@kbadkowski
Looks like the build is taking a long time and causing the toolkit to timeout. Try adjusting this setting
aws.samcli.lambda.timeoutto a higher value, maybe double or more. The value is in milliseconds.A fast way to find the setting is by running the command
Preferences: Open User Settingsthen pastingaws.samcli.lambda.timeoutinto the settings search bar.Updates regarding timeouts in SAM debug flows are partially tracked apart of this issue: https://github.com/aws/aws-toolkit-vscode/issues/2455