aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

sam build fails with "AWS quick start -> Java 11 -> Docker"

Open vilunet opened this issue 5 years ago • 3 comments

Description:

Build fails with docker build at step 8 - File Not Found

Steps to reproduce:

Just run AWS quick start to create a sample app and run sam build.

Observed result:

Step 7/16 : COPY gradle/lambda-build-init.gradle ./build ---> Using cache ---> bfaaeb63805a Step 8/16 : RUN ./gradlew --project-cache-dir $SCRATCH_DIR/gradle-cache -Dsoftware.amazon.aws.lambdabuilders.scratch-dir=$SCRATCH_DIR --init-script $SCRATCH_DIR/lambda-build-init.gradle build ---> Running in 37994a9fdc4b ←[0m←[91m: No such file or directory ←[0m Build Failed Error: HelloWorldFunction failed to build: The command '/bin/sh -c ./gradlew --project-cache-dir $SCRATCH_DIR/gradle-cache -Dsoftware.amazon.aws.lambdabuilders.scratch-dir=$SCRATCH_DIR --init-script $SCRATCH_DIR/lambda-build-init.gradle build' returned a non-zero code: 127

Expected result:

build should return no error

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows 10 - Powershell
  2. sam --version: 1.15.0

vilunet avatar Jan 25 '21 04:01 vilunet

Update: cannot reproduce it on macOS with hello world (zip) template. ~Will try it on windows~

I can reproduce it on windows 10, powershell, same template:

Starting Build inside a container
Building codeuri: HelloWorldFunction runtime: java11 metadata: {} functions: ['HelloWorldFunction']

Fetching amazon/aws-sam-cli-build-image-java11 Docker container image.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Mounting C:\Users\xinho\Downloads\sam-app-20210125\HelloWorldFunction as /tmp/samcli/source:ro,delegated inside runtime container

Build Failed
: No such file or directoryradleBuild - Gradle Failed: /usr/bin/env: sh

Possible cause: the script being run has \r in it: https://stackoverflow.com/questions/29045140/env-bash-r-no-such-file-or-directory

aahung avatar Jan 25 '21 18:01 aahung

This issue is due to git pulling the quick start repo with \r\n as the line ending on Windows. A workaround is to modify gradlew and replace all \r\n to \n

CoshUS avatar Mar 18 '21 20:03 CoshUS

Fixed in 1.22.0 release.

CoshUS avatar Apr 07 '21 00:04 CoshUS