Bug: sam local start-api fails to build docker image
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
When I run `sam local start-api` for a rust lambda sam project, it fails to build the docker image neccessary to emulate the rust lambda functions locally.
### Steps to reproduce:
I created a rust lambda project and ran `sam local start-api` to run the lambda api locally.
### Observed result:
```
2025-01-08 15:49:32,325 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/organization
2025-01-08 15:49:32,326 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/organization
2025-01-08 15:49:32,325 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/device
2025-01-08 15:49:32,327 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/organization
2025-01-08 15:49:32,329 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/organization
2025-01-08 15:49:32,346 | watch resource /home/nrgxp/fleet-management-api/target/lambda/auth
2025-01-08 15:49:32,347 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/auth with recursive True
2025-01-08 15:49:32,349 | watch resource /home/nrgxp/fleet-management-api/target/lambda/auth's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,350 | Code /home/nrgxp/fleet-management-api/target/lambda/auth is not a zip/jar file
2025-01-08 15:49:32,353 | Local image was not found.
2025-01-08 15:49:32,396 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image.....2025-01-08 15:49:32,511 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt
2025-01-08 15:49:32,512 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt with recursive True
2025-01-08 15:49:32,514 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,516 | Code /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt is not a zip/jar file
2025-01-08 15:49:32,519 | Local image was not found.
2025-01-08 15:49:32,521 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image.....2025-01-08 15:49:32,595 | watch resource /home/nrgxp/fleet-management-api/target/lambda/deployment
2025-01-08 15:49:32,596 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/deployment with recursive True
2025-01-08 15:49:32,598 | watch resource /home/nrgxp/fleet-management-api/target/lambda/deployment's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,600 | Code /home/nrgxp/fleet-management-api/target/lambda/deployment is not a zip/jar file
2025-01-08 15:49:32,604 | Local image was not found.
2025-01-08 15:49:32,605 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image.....2025-01-08 15:49:32,712 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota
2025-01-08 15:49:32,713 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/device-ota with recursive True
2025-01-08 15:49:32,715 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,716 | Code /home/nrgxp/fleet-management-api/target/lambda/device-ota is not a zip/jar file
2025-01-08 15:49:32,719 | Local image was not found.
2025-01-08 15:49:32,720 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image.....2025-01-08 15:49:32,756 | watch resource /home/nrgxp/fleet-management-api/target/lambda/group
2025-01-08 15:49:32,757 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/group with recursive True
2025-01-08 15:49:32,759 | watch resource /home/nrgxp/fleet-management-api/target/lambda/group's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,760 | Code /home/nrgxp/fleet-management-api/target/lambda/group is not a zip/jar file
2025-01-08 15:49:32,763 | Local image was not found.
2025-01-08 15:49:32,765 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image...2025-01-08 15:49:32,819 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device
2025-01-08 15:49:32,820 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/device with recursive True
2025-01-08 15:49:32,822 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,824 | Code /home/nrgxp/fleet-management-api/target/lambda/device is not a zip/jar file
2025-01-08 15:49:32,828 | Local image was not found.
2025-01-08 15:49:32,830 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image...2025-01-08 15:49:32,878 | watch resource /home/nrgxp/fleet-management-api/target/lambda/organization
2025-01-08 15:49:32,879 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/organization with recursive True
2025-01-08 15:49:32,881 | watch resource /home/nrgxp/fleet-management-api/target/lambda/organization's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:32,883 | Code /home/nrgxp/fleet-management-api/target/lambda/organization is not a zip/jar file
2025-01-08 15:49:32,886 | Local image was not found.
2025-01-08 15:49:32,888 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image......................................................................................................
2025-01-08 15:49:34,169 | Failed to build Docker Image
NoneType: None
2025-01-08 15:49:34,174 | Loading AWS credentials from session with profile 'None'
..
2025-01-08 15:49:34,264 | Failed to build Docker Image
NoneType: None
2025-01-08 15:49:34,268 | Loading AWS credentials from session with profile 'None'
......
2025-01-08 15:49:34,407 | Failed to build Docker Image
NoneType: None
2025-01-08 15:49:34,413 | Loading AWS credentials from session with profile 'None'
.
2025-01-08 15:49:34,471 | Failed to build Docker Image
NoneType: None
.
2025-01-08 15:49:34,529 | Failed to build Docker Image
NoneType: None
.
2025-01-08 15:49:34,550 | Failed to build Docker Image
NoneType: None
.
2025-01-08 15:49:34,561 | Failed to build Docker Image
NoneType: None
.
2025-01-08 15:49:34,567 | Failed to build Docker Image
NoneType: None
2025-01-08 15:49:36,189 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/product
2025-01-08 15:49:36,191 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/product
2025-01-08 15:49:36,191 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/product
2025-01-08 15:49:36,192 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/product
2025-01-08 15:49:36,230 | watch resource /home/nrgxp/fleet-management-api/target/lambda/product
2025-01-08 15:49:36,231 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/product with recursive True
2025-01-08 15:49:36,233 | watch resource /home/nrgxp/fleet-management-api/target/lambda/product's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:36,234 | Code /home/nrgxp/fleet-management-api/target/lambda/product is not a zip/jar file
2025-01-08 15:49:36,236 | Local image was not found.
2025-01-08 15:49:36,236 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image...2025-01-08 15:49:36,290 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/release
2025-01-08 15:49:36,291 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/release
2025-01-08 15:49:36,292 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/release
2025-01-08 15:49:36,293 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/release
2025-01-08 15:49:36,308 | watch resource /home/nrgxp/fleet-management-api/target/lambda/release
2025-01-08 15:49:36,309 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/release with recursive True
2025-01-08 15:49:36,311 | watch resource /home/nrgxp/fleet-management-api/target/lambda/release's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:36,312 | Code /home/nrgxp/fleet-management-api/target/lambda/release is not a zip/jar file
2025-01-08 15:49:36,315 | Local image was not found.
2025-01-08 15:49:36,316 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image.......2025-01-08 15:49:36,436 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/stage
2025-01-08 15:49:36,437 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/stage
2025-01-08 15:49:36,438 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/stage
2025-01-08 15:49:36,439 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/stage
2025-01-08 15:49:36,449 | watch resource /home/nrgxp/fleet-management-api/target/lambda/stage
2025-01-08 15:49:36,449 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/stage with recursive True
2025-01-08 15:49:36,451 | watch resource /home/nrgxp/fleet-management-api/target/lambda/stage's parent /home/nrgxp/fleet-management-api/target/lambda
2025-01-08 15:49:36,452 | Code /home/nrgxp/fleet-management-api/target/lambda/stage is not a zip/jar file
2025-01-08 15:49:36,454 | Local image was not found.
2025-01-08 15:49:36,454 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023
Building image..........................................
2025-01-08 15:49:37,562 | Failed to build Docker Image
NoneType: None
.
2025-01-08 15:49:37,634 | Failed to build Docker Image
NoneType: None
.
2025-01-08 15:49:37,640 | Failed to build Docker Image
NoneType: None
2025-01-08 15:49:37,643 | Exception raised during the execution
2025-01-08 15:49:37,644 | Lambda functions containers initialization failed because of Error building docker image: The command '/bin/sh -c mv /var/rapid/aws-lambda-rie-x86_64 /var/rapid/aws-lambda-rie && chmod +x
/var/rapid/aws-lambda-rie' returned a non-zero code: 127
```
### Expected result:
I expect it to build the docker images for rust lambda emulation without any errors.
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
```
{
"version": "1.132.0",
"system": {
"python": "3.11.10",
"os": "Linux-6.8.0-51-generic-x86_64-with-glibc2.39"
},
"additional_dependencies": {
"docker_engine": "27.4.1",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
```
`Add --debug flag to command you are running`
Contributor guide
Assessment
This issue has not been assessed yet.