-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"sam build -u -e TARGET_CC=foo" leads to "cargo: Command not found" #3132
Comments
For completeness, here's the containers that I have on amazon/aws-sam-cli-emulation-image-provided.al2 rapid-1.27.2 6e864f19bc63 5 days ago 244MB
public.ecr.aws/sam/build-provided.al2 latest 4f70a87adc2f 11 days ago 1.88GB
amazon/aws-sam-cli-emulation-image-provided.al2 latest 70efd43277f7 11 days ago 227MB
amazon/aws-sam-cli-emulation-image-provided.al2 rapid-1.24.1 9f3e53a81136 6 weeks ago 244MB
amazon/aws-sam-cli-emulation-image-provided.al2 <none> b688c0edef90 7 weeks ago 227MB
amazon/aws-sam-cli-emulation-image-python3.8 rapid-1.22.0.dev202104291816 857b0163bb0b 2 months ago 516MB
amazon/aws-sam-cli-emulation-image-python3.8 latest a2d941bb092d 2 months ago 500MB But it doesn't matter because after wiping them all:
and rerunning
Which leads me to believe that passing environment variables might wipe or mangle $PATH too within the container? |
@brainstorm In your case, the
1 will work but you will be installing |
Thanks @jfuss, I understand the issue better now, although I see that it'll get a bit more complex before it gets easier?: index 09a3175..7515a02 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
build-s3Bam:
# TODO: Put conditional code depending on arch... for now it will lead to Exec error anyway though unless it's x86_64 provided.al2 :/
# Intel GNU
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo build --release --target x86_64-unknown-linux-gnu
cp ./target/x86_64-unknown-linux-gnu/release/bootstrap $(ARTIFACTS_DIR)
# I'd like to build on top of % sam build -u -bi public.ecr.aws/sam/build-provided.al2
Starting Build inside a container
Building codeuri: /Users/rvalls/dev/umccr/s3-rust-noodles-bam runtime: provided.al2 metadata: {'BuildMethod': 'makefile'} functions: ['s3Bam']
Fetching public.ecr.aws/sam/build-provided.al2 Docker container image......
Mounting /Users/rvalls/dev/umccr/s3-rust-noodles-bam as /tmp/samcli/source:ro,delegated inside runtime container
Build Failed
Running CustomMakeBuilder:CopySource
Running CustomMakeBuilder:MakeBuild
Current Artifacts Directory : /tmp/samcli/artifacts
Error: CustomMakeBuilder:MakeBuild - Make Failed: /usr/bin/head: error reading ‘/proc/self/exe’: Bad file descriptor
/usr/bin/head: failed to close ‘/proc/self/exe’: Bad file descriptor
rustup: unknown platform bitness
/usr/bin/sh: line 358: [: : integer expression expected
info: downloading installer
rustup: Unable to run interactively. Run with -y to accept defaults, --help for additional options
make: *** [build-s3Bam] Error 1 Also, how can I define a build-only target on the same Makefile without interfering with the default % git diff Makefile
diff --git a/Makefile b/Makefile
index 09a3175..614bb06 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
+build-only-container:
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+ # TODO: Other build-only related commands
+ cargo build --release --target x86_64-unknown-linux-gnu
+ cp ./target/x86_64-unknown-linux-gnu/release/bootstrap $(ARTIFACTS_DIR)
# Host-only sam build target
build-s3Bam:
cargo build --release --target x86_64-unknown-linux-gnu
cp ./target/x86_64-unknown-linux-gnu/release/bootstrap $(ARTIFACTS_DIR) Or perhaps I should drop See https://github.com/umccr/s3-rust-noodles-bam/blob/d93d79a7e9d78e54bfb0cf141350f28986e26463/Makefile for more context. |
Also, is it possible to pass a |
Not sure what you mean by this. The build-provided.al1 image should be a good base. You may need to install tools you need into the image though.
Not sure I understand the question here. Are you trying to build some functions locally, while others in a container? If so that is not supported. #1825 is similar to this and I don't think we have a specific issue to cover this use-case yet.
No. You can provide a customer image but we don't allow mounting of volumes into the build container. |
Sorry, I'll try to be more specific: I have been looking around the AWS ECR public registry here: https://gallery.ecr.aws/?operatingSystems=Linux&architectures=x86-64%2Cx86&searchTerm=lambda
Apologies again, what I meant was whether there was a possibility to ship the container building "recipe"/Dockerfile along with the SAM cli project itself, as in:
But nevermind about this question, I guess that such a building container needs to be built separatedly now. I'll now try and build a container with the docs I referred to above in https://github.com/aws/aws-lambda-base-images and report back, thanks for the support and guidance, @jfuss. |
So I went and did a:
Which built
Which is a confusing error messages because the base-images repo seems to be updated quite recently and frequently: https://github.com/aws/aws-lambda-base-images/commits/provided.al2 Is there an easy way to bypass that "not compatible |
I've now found https://github.com/aws/aws-sam-build-images/blob/develop/build-image-src/Dockerfile-provided-al2 ... which I guess it's the proper official SAM CLI lambda docker image(s). |
Some progress while using Given those minor changes (installing the rust toolchain via rustup): Dockerfile-provided-al2 diff, just adding Rust toolchaindiff --git a/build-image-src/Dockerfile-provided-al2 b/build-image-src/Dockerfile-provided-al2
index 4c08d59..0225860 100644
--- a/build-image-src/Dockerfile-provided-al2
+++ b/build-image-src/Dockerfile-provided-al2
@@ -42,7 +42,12 @@ RUN curl -L "https://github.com/awslabs/aws-sam-cli/archive/v$SAM_CLI_VERSION.zi
/usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install ./aws-sam-cli-$SAM_CLI_VERSION && \
rm samcli.zip && rm -rf aws-sam-cli-$SAM_CLI_VERSION
-ENV PATH=$PATH:/usr/local/opt/sam-cli/bin
+# Install cargo and other Rust friends
+RUN curl -L "https://sh.rustup.rs" -o "rustup.sh"
+RUN chmod +x rustup.sh && sh rustup.sh -y
+RUN ls -alh $HOME/.cargo/bin/
+
+ENV PATH=$PATH:/usr/local/opt/sam-cli/bin:$HOME/.cargo/bin
ENV LANG=en_US.UTF-8 And then rebuilding the container via docker cross-building: Building provided-al2 container via "docker buildx build --platform=linux/amd64..."% docker buildx build --progress tty --platform=linux/amd64 -f Dockerfile-provided-al2 -t amazon/aws-sam-cli-build-image-provided.al2 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION .
[+] Building 113.4s (18/18) FINISHED
=> [internal] load build definition from Dockerfile-provided-al2 0.4s
=> => transferring dockerfile: 45B 0.0s
=> [internal] load .dockerignore 0.6s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/amazon/aws-sam-cli-emulation-image-java8.al2:latest 1.6s
=> [internal] load metadata for docker.io/library/amazonlinux:2 1.7s
=> [stage-1 1/3] FROM docker.io/library/amazonlinux:2@sha256:93e55c026fe5dba304ff3f24690b07cb39f610b160844a575bb8f3fec41b3a5e 0.0s
=> [internal] load build context 0.4s
=> => transferring context: 38B 0.0s
=> [stage-0 1/1] FROM docker.io/amazon/aws-sam-cli-emulation-image-java8.al2@sha256:fd619bdf4ebe812b54784c8d6f28af25730a76337e7acd088dad3e9065fcdbf8 0.2s
=> => resolve docker.io/amazon/aws-sam-cli-emulation-image-java8.al2@sha256:fd619bdf4ebe812b54784c8d6f28af25730a76337e7acd088dad3e9065fcdbf8 0.2s
=> CACHED [stage-1 2/3] COPY --from=0 / /rootfs 0.0s
=> CACHED [stage-1 3/3] RUN yum groupinstall -y development --installroot=/rootfs && yum install -d1 --installroot=/rootfs -y yum tar gzip unzip python3 jq grep curl make rsync binutils gcc-c++ procps libgmp3-dev zlib1g-dev liblzma-dev libxslt-devel libmpc-devel && yum clean all 0.0s
=> CACHED [stage-2 2/9] COPY --from=1 /rootfs / 0.0s
=> CACHED [stage-2 3/9] RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install && rm awscliv2.zip && rm -rf ./aws 0.0s
=> CACHED [stage-2 4/9] RUN curl -L "https://github.com/awslabs/aws-sam-cli/archive/v1.28.0.zip" -o "samcli.zip" && unzip samcli.zip && python3 -m venv /usr/local/opt/sam-cli && /usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install -r ./aws-sam-cli-1.28.0/requirements/reproducible-linux.txt && /usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install ./aws-sam-cli-1.28.0 && rm samcli.zip && rm -rf aws-sam-cli-1.28.0 0.0s
=> [stage-2 5/9] RUN curl -L "https://sh.rustup.rs" -o "rustup.sh" 1.8s
=> [stage-2 6/9] RUN chmod +x rustup.sh && sh rustup.sh -y 97.2s
=> [stage-2 7/9] RUN ls -alh $HOME/.cargo/bin/ 1.6s
=> [stage-2 8/9] RUN pip3 install wheel 4.5s
=> [stage-2 9/9] COPY ATTRIBUTION.txt / 0.9s
=> exporting to image 4.2s
=> => exporting layers 3.9s
=> => writing image sha256:d37f65f4ead6d286f07b344409e0e0a30a39bb08a2fd8652afde09e63d615f7a 0.0s
=> => naming to docker.io/amazon/aws-sam-cli-build-image-provided.al2 Cargo is not being found because of Cargo not found% sam build --debug -u -bi amazon/aws-sam-cli-build-image-provided.al2 --skip-pull-image -e PATH=$PATH:/home/ec2-user/.cargo/bin
2021-08-23 15:35:48,641 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-08-23 15:35:48,641 | Using config file: samconfig.toml, config environment: default
2021-08-23 15:35:48,641 | Expand command line arguments to:
2021-08-23 15:35:48,641 | --template_file=/Users/rvalls/dev/umccr/s3-rust-noodles-bam/template.yml --use_container --build_image=('amazon/aws-sam-cli-build-image-provided.al2',) --skip_pull_image --container_env_var=('PATH=/opt/homebrew/opt/curl/bin:/Users/rvalls/.mambaforge/bin:/Users/rvalls/.mambaforge/condabin:/opt/homebrew/opt/coreutils/libexec/gnubin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/rvalls/.cargo/bin:/home/ec2-user/.cargo/bin',) --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache
2021-08-23 15:35:48,697 | 'build' command is called
2021-08-23 15:35:48,697 | Starting Build inside a container
2021-08-23 15:35:48,699 | No Parameters detected in the template
2021-08-23 15:35:48,711 | 2 stacks found in the template
2021-08-23 15:35:48,711 | No Parameters detected in the template
2021-08-23 15:35:48,727 | 2 resources found in the stack
2021-08-23 15:35:48,727 | No Parameters detected in the template
2021-08-23 15:35:48,736 | Found Serverless function with name='s3Bam' and CodeUri='.'
2021-08-23 15:35:48,736 | --base-dir is not presented, adjusting uri . relative to /Users/rvalls/dev/umccr/s3-rust-noodles-bam/template.yml
2021-08-23 15:35:48,736 | No Parameters detected in the template
2021-08-23 15:35:48,747 | Instantiating build definitions
2021-08-23 15:35:48,749 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(provided.al2, /Users/rvalls/dev/umccr/s3-rust-noodles-bam, Zip, , 6820be7d-0ff1-4e23-9eb1-03994e2db6f4, {'BuildMethod': 'makefile'}, {'PATH': '/opt/homebrew/opt/curl/bin:/Users/rvalls/.mambaforge/bin:/Users/rvalls/.mambaforge/condabin:/opt/homebrew/opt/coreutils/libexec/gnubin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/rvalls/.cargo/bin:/home/ec2-user/.cargo/bin'}, []), Function: Function(name='s3Bam', functionname='s3-bamheader', runtime='provided.al2', memory=128, timeout=30, handler='bootstrap.is.real.handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/Users/rvalls/dev/umccr/s3-rust-noodles-bam', environment=None, rolearn=None, layers=[], events={'RootEvent': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'any', 'RestApiId': 'ServerlessRestApi'}}, 'GatewayEvent': {'Type': 'Api', 'Properties': {'Path': '/{proxy+}', 'Method': 'any', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'BuildMethod': 'makefile'}, inlinecode=None, codesign_config_arn=None, stack_path=''))
2021-08-23 15:35:48,750 | Building codeuri: /Users/rvalls/dev/umccr/s3-rust-noodles-bam runtime: provided.al2 metadata: {'BuildMethod': 'makefile'} functions: ['s3Bam']
2021-08-23 15:35:48,750 | Building to following folder /Users/rvalls/dev/umccr/s3-rust-noodles-bam/.aws-sam/build/s3Bam
2021-08-23 15:35:48,771 | Requested to skip pulling images ...
2021-08-23 15:35:48,771 | Mounting /Users/rvalls/dev/umccr/s3-rust-noodles-bam as /tmp/samcli/source:ro,delegated inside runtime container
Build Failed
2021-08-23 15:35:52,253 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '7a75ec26-92e1-485d-9709-1c5578c2319d', 'installationId': 'b0a4feb6-813d-4f61-952f-5919f29d6b17', 'sessionId': '160f561e-7cd4-4367-bcd0-9a4d47be20e8', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.11', 'samcliVersion': '1.28.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 3611, 'exitReason': 'UnsupportedBuilderLibraryVersionError', 'exitCode': 1}}]}
2021-08-23 15:35:53,098 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: You are running an outdated version of Docker container 'amazon/aws-sam-cli-build-image-provided.al2' that is not compatible withthis version of SAM CLI. Please upgrade to continue to continue with build. Reason: 'lambda-builders executable not found in container'
(base) rvalls@m1 s3-rust-noodles-bam % sam build --debug -u -bi amazon/aws-sam-cli-build-image-provided.al2 --skip-pull-image
2021-08-23 15:40:33,061 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-08-23 15:40:33,061 | Using config file: samconfig.toml, config environment: default
2021-08-23 15:40:33,061 | Expand command line arguments to:
2021-08-23 15:40:33,062 | --template_file=/Users/rvalls/dev/umccr/s3-rust-noodles-bam/template.yml --use_container --build_image=('amazon/aws-sam-cli-build-image-provided.al2',) --skip_pull_image --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache
2021-08-23 15:40:33,137 | 'build' command is called
2021-08-23 15:40:33,137 | Starting Build inside a container
2021-08-23 15:40:33,139 | No Parameters detected in the template
2021-08-23 15:40:33,151 | 2 stacks found in the template
2021-08-23 15:40:33,151 | No Parameters detected in the template
2021-08-23 15:40:33,168 | 2 resources found in the stack
2021-08-23 15:40:33,169 | No Parameters detected in the template
2021-08-23 15:40:33,178 | Found Serverless function with name='s3Bam' and CodeUri='.'
2021-08-23 15:40:33,178 | --base-dir is not presented, adjusting uri . relative to /Users/rvalls/dev/umccr/s3-rust-noodles-bam/template.yml
2021-08-23 15:40:33,178 | No Parameters detected in the template
2021-08-23 15:40:33,189 | Instantiating build definitions
2021-08-23 15:40:33,192 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(provided.al2, /Users/rvalls/dev/umccr/s3-rust-noodles-bam, Zip, , af6db324-c90e-4f89-9c33-84dec6d7ac8d, {'BuildMethod': 'makefile'}, {}, []), Function: Function(name='s3Bam', functionname='s3-bamheader', runtime='provided.al2', memory=128, timeout=30, handler='bootstrap.is.real.handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/Users/rvalls/dev/umccr/s3-rust-noodles-bam', environment=None, rolearn=None, layers=[], events={'RootEvent': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'any', 'RestApiId': 'ServerlessRestApi'}}, 'GatewayEvent': {'Type': 'Api', 'Properties': {'Path': '/{proxy+}', 'Method': 'any', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'BuildMethod': 'makefile'}, inlinecode=None, codesign_config_arn=None, stack_path=''))
2021-08-23 15:40:33,194 | Building codeuri: /Users/rvalls/dev/umccr/s3-rust-noodles-bam runtime: provided.al2 metadata: {'BuildMethod': 'makefile'} functions: ['s3Bam']
2021-08-23 15:40:33,194 | Building to following folder /Users/rvalls/dev/umccr/s3-rust-noodles-bam/.aws-sam/build/s3Bam
2021-08-23 15:40:33,223 | Requested to skip pulling images ...
2021-08-23 15:40:33,223 | Mounting /Users/rvalls/dev/umccr/s3-rust-noodles-bam as /tmp/samcli/source:ro,delegated inside runtime container
Using the request object from command line argument
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
Found workflow 'CustomMakeBuilder' to support capabilities 'Capability(language='provided', dependency_manager=None, application_framework=None)'
Running workflow 'CustomMakeBuilder'
Running CustomMakeBuilder:CopySource
CustomMakeBuilder:CopySource succeeded
Running CustomMakeBuilder:MakeBuild
Current Artifacts Directory : /tmp/samcli/artifacts
executing Make: ['make', '--makefile', '/tmp/samcli/source/Makefile', 'build-s3Bam']
CustomMakeBuilder:MakeBuild failed
Traceback (most recent call last):
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflows/custom_make/actions.py", line 94, in execute
cwd=self.scratch_dir,
File "/usr/local/opt/sam-cli/lib64/python3.7/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: cargo: Command not found
make: *** [build-s3Bam] Error 127
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflow.py", line 269, in run
action.execute()
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflows/custom_make/actions.py", line 97, in execute
raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Make Failed: make: cargo: Command not found
make: *** [build-s3Bam] Error 127
Builder workflow failed
Traceback (most recent call last):
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflows/custom_make/actions.py", line 94, in execute
cwd=self.scratch_dir,
File "/usr/local/opt/sam-cli/lib64/python3.7/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: cargo: Command not found
make: *** [build-s3Bam] Error 127
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflow.py", line 269, in run
action.execute()
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflows/custom_make/actions.py", line 97, in execute
raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Make Failed: make: cargo: Command not found
make: *** [build-s3Bam] Error 127
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/__main__.py", line 126, in main
mode=params.get("mode", None),
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/builder.py", line 125, in build
return workflow.run()
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflow.py", line 76, in wrapper
func(self, *args, **kwargs)
File "/usr/local/opt/sam-cli/lib64/python3.7/site-packages/aws_lambda_builders/workflow.py", line 276, in run
raise WorkflowFailedError(workflow_name=self.NAME, action_name=action.NAME, reason=str(ex))
aws_lambda_builders.exceptions.WorkflowFailedError: CustomMakeBuilder:MakeBuild - Make Failed: make: cargo: Command not found
make: *** [build-s3Bam] Error 127
2021-08-23 15:42:12,018 | Build inside container returned response {"jsonrpc": "2.0", "id": 1, "error": {"code": 400, "message": "CustomMakeBuilder:MakeBuild - Make Failed: make: cargo: Command not found\nmake: *** [build-s3Bam] Error 127"}}
Build Failed
2021-08-23 15:42:15,593 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'd3bea992-dfd1-4e66-88a0-de73064136ed', 'installationId': 'b0a4feb6-813d-4f61-952f-5919f29d6b17', 'sessionId': 'cc4826ec-cc8d-4394-9c38-15d6fd4f4591', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.11', 'samcliVersion': '1.28.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 102528, 'exitReason': 'BuildInsideContainerError', 'exitCode': 1}}]}
2021-08-23 15:42:16,408 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: CustomMakeBuilder:MakeBuild - Make Failed: make: cargo: Command not found
make: *** [build-s3Bam] Error 127 But then, when passing $PATH inside the container not appendable with `sam build -e`?(base) rvalls@m1 s3-rust-noodles-bam % sam build --debug -u -bi amazon/aws-sam-cli-build-image-provided.al2 --skip-pull-image -e PATH=$PATH:/home/ec2-user/.cargo/bin
2021-08-23 15:51:23,428 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-08-23 15:51:23,428 | Using config file: samconfig.toml, config environment: default
2021-08-23 15:51:23,428 | Expand command line arguments to:
2021-08-23 15:51:23,428 | --template_file=/Users/rvalls/dev/umccr/s3-rust-noodles-bam/template.yml --use_container --build_image=('amazon/aws-sam-cli-build-image-provided.al2',) --skip_pull_image --container_env_var=('PATH=/opt/homebrew/opt/curl/bin:/Users/rvalls/.mambaforge/bin:/Users/rvalls/.mambaforge/condabin:/opt/homebrew/opt/coreutils/libexec/gnubin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/rvalls/.cargo/bin:/home/ec2-user/.cargo/bin',) --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache
2021-08-23 15:51:23,457 | 'build' command is called
2021-08-23 15:51:23,457 | Starting Build inside a container
2021-08-23 15:51:23,459 | No Parameters detected in the template
2021-08-23 15:51:23,471 | 2 stacks found in the template
2021-08-23 15:51:23,471 | No Parameters detected in the template
2021-08-23 15:51:23,487 | 2 resources found in the stack
2021-08-23 15:51:23,487 | No Parameters detected in the template
2021-08-23 15:51:23,496 | Found Serverless function with name='s3Bam' and CodeUri='.'
2021-08-23 15:51:23,497 | --base-dir is not presented, adjusting uri . relative to /Users/rvalls/dev/umccr/s3-rust-noodles-bam/template.yml
2021-08-23 15:51:23,497 | No Parameters detected in the template
2021-08-23 15:51:23,507 | Instantiating build definitions
2021-08-23 15:51:23,510 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(provided.al2, /Users/rvalls/dev/umccr/s3-rust-noodles-bam, Zip, , 42c58a46-681a-40d6-b870-0220c2ec8751, {'BuildMethod': 'makefile'}, {'PATH': '/opt/homebrew/opt/curl/bin:/Users/rvalls/.mambaforge/bin:/Users/rvalls/.mambaforge/condabin:/opt/homebrew/opt/coreutils/libexec/gnubin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/rvalls/.cargo/bin:/home/ec2-user/.cargo/bin'}, []), Function: Function(name='s3Bam', functionname='s3-bamheader', runtime='provided.al2', memory=128, timeout=30, handler='bootstrap.is.real.handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/Users/rvalls/dev/umccr/s3-rust-noodles-bam', environment=None, rolearn=None, layers=[], events={'RootEvent': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'any', 'RestApiId': 'ServerlessRestApi'}}, 'GatewayEvent': {'Type': 'Api', 'Properties': {'Path': '/{proxy+}', 'Method': 'any', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'BuildMethod': 'makefile'}, inlinecode=None, codesign_config_arn=None, stack_path=''))
2021-08-23 15:51:23,511 | Building codeuri: /Users/rvalls/dev/umccr/s3-rust-noodles-bam runtime: provided.al2 metadata: {'BuildMethod': 'makefile'} functions: ['s3Bam']
2021-08-23 15:51:23,511 | Building to following folder /Users/rvalls/dev/umccr/s3-rust-noodles-bam/.aws-sam/build/s3Bam
2021-08-23 15:51:23,524 | Requested to skip pulling images ...
2021-08-23 15:51:23,524 | Mounting /Users/rvalls/dev/umccr/s3-rust-noodles-bam as /tmp/samcli/source:ro,delegated inside runtime container
Build Failed
2021-08-23 15:51:26,281 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '3a3a6221-9cb3-4bad-a828-bcfd7cd671fa', 'installationId': 'b0a4feb6-813d-4f61-952f-5919f29d6b17', 'sessionId': '8196b43f-8961-49f2-bcc9-d791df4c0102', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.11', 'samcliVersion': '1.28.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 2852, 'exitReason': 'UnsupportedBuilderLibraryVersionError', 'exitCode': 1}}]}
2021-08-23 15:51:27,228 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: You are running an outdated version of Docker container 'amazon/aws-sam-cli-build-image-provided.al2' that is not compatible withthis version of SAM CLI. Please upgrade to continue to continue with build. Reason: 'lambda-builders executable not found in container' Telemetry most likely fails because when passing the new I'll keep digging on this, but happy to hear feedback if there's an easier path to all this, @jfuss et al ;) |
Unfortunately, passing in an
{
"Parameters": {
"PATH": "$PATH:$HOME/.cargo/bin"
}
} Yields similar results:
|
Thanks to @hoffa I managed to fix this in aws/aws-sam-build-images#26 (comment) ... unfortunately the |
Nevermind, the AWS Rust team is doing a great job with |
yes, cargo lambda is great until one depends on native C library such as |
Description:
I'm trying to pass build variables to the
sam build
docker container to solve briansmith/ring#1332 cross-compiling issue, also pointed out over twitter.Steps to reproduce:
On an Apple Silicon M1 laptop, run the following:
Observed result:
When
sam build
is called with environment variable container-passing flag,cargo
command is not found:When calling
sam build
with no arguments,cargo
seems to be there in theprovided.al2
container:Expected result:
I expect
sam build
to correctly cross-compile ax86_64-unknown-linux-gnu
Rust lambda that runs on aprovided.al2
container without involving MUSL.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.27.2ap-southeast-2
otherwiseThe text was updated successfully, but these errors were encountered: