Aws-sam-cli: Go quickstart hello world example fails to run

Created on 1 Aug 2020  路  7Comments  路  Source: aws/aws-sam-cli

Description

After deploying the Go Hello World quickstart example (without any modifications), the deployed Lambda fails to run, with a file not found error.

Steps to reproduce

  1. sam init --runtime go1.x
  2. Select the Hello World Example
  3. make the project (or sam build)
  4. sam deploy --guided
  5. Either hit the deployed API, or test the Lambda via the console
  6. Observe the function fails to execute

Observed result

The following error is visible in the Lambda console:

{
  "errorMessage": "fork/exec /var/task/hello-world: no such file or directory",
  "errorType": "PathError"
}

Expected result

The Lambda executes.

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

  1. OS: Ubuntu 20.04, kernal 5.4.0-42
  2. sam --version: SAM CLI, version 1.0.0
  3. go version: go version go1.14.5 linux/amd64
stagbug-repro typbug

Most helpful comment

This also occurs with the following environment details:

  1. OS: Windows 10, Version 1809 (OS Build 17763.1339)
  2. sam --version: SAM CLI, version 1.0.0
  3. go version: go1.14.6 windows/amd64

Seems to be related to executable permissions:

ls .aws-sam/build/HelloWorldFunction

    Directory: ~\source\foo\.aws-sam\build\HelloWorldFunction

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         8/6/2020  10:29 AM        9967550 hello-world

All 7 comments

This also occurs with the following environment details:

  1. OS: Windows 10, Version 1809 (OS Build 17763.1339)
  2. sam --version: SAM CLI, version 1.0.0
  3. go version: go1.14.6 windows/amd64

Seems to be related to executable permissions:

ls .aws-sam/build/HelloWorldFunction

    Directory: ~\source\foo\.aws-sam\build\HelloWorldFunction

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         8/6/2020  10:29 AM        9967550 hello-world

However, this works as expected on macOS with the following environment details:

  1. OS: macOS Catalina Version 10.15.6
  2. sam --version: SAM CLI, version 1.0.0
  3. go version: go1.14.6 darwin/amd64

This also occurs with the following environment details:

  1. OS: Windows 10, Version 1809 (OS Build 17763.1339)
  2. sam --version: SAM CLI, version 1.0.0
  3. go version: go1.14.6 windows/amd64

Seems to be related to executable permissions:

ls .aws-sam/build/HelloWorldFunction

    Directory: ~\source\foo\.aws-sam\build\HelloWorldFunction

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         8/6/2020  10:29 AM        9967550 hello-world

Duplicate with: https://github.com/awslabs/aws-sam-cli/issues/954

Original issue could a different one since the error message is path not found and I wasn't able to reproduce it yet.

Having the same issue, is there a workaround?

  • Ubuntu 20.04.1 LTS
  • SAM CLI, version 1.4.0
  • go version go1.14.4 linux/amd64

One workaround is to provision a Cloud9 instance. I just tested this with the default install and everything works as expected. The smallest instance type _t2.micro_ should be fine, and may fall within the free tier depending on your account age and usage. See Cloud9 Pricing for more information.

NOTE: You must choose "Amazon Linux" as the Platform, not Ubuntu Server 18.04 LTS. It does not work on Ubuntu Server 18.04 LTS.

Working Cloud9 info:

  1. OS: Amazon Linux 2018.03
  2. sam --version: SAM CLI, version 1.3.2
  3. go version: go1.13.14 linux/amd64

One workaround is to provision a Cloud9 instance. I just tested this with the default install and everything works as expected. The smallest instance type _t2.micro_ should be fine, and may fall within the free tier depending on your account age and usage. See Cloud9 Pricing for more information.

NOTE: You must choose "Amazon Linux" as the Platform, not Ubuntu Server 18.04 LTS. It does not work on Ubuntu Server 18.04 LTS.

Working Cloud9 info:

  1. OS: Amazon Linux 2018.03
  2. sam --version: SAM CLI, version 1.3.2
  3. go version: go1.13.14 linux/amd64

Thank you for the response. My issue occurred because I use gvm and I wasn't in the right path prior to compiling the project.

When I run gvm use go1. X. X then compile and deploy, the problem was solved.

I was not able to reproduce this issue. As @yogesnsamy mentioned, this could be a setup error.

Thank you for the response. My issue occurred because I use gvm and I wasn't in the right path prior to compiling the project.
When I run gvm use go1. X. X then compile and deploy, the problem was solved.

Regarding the Windows permission issue @rts-rob brought up, it is tracked and fixed in a separate issue. #954

Closing this issue, feel free to reopen if anyone has more info on this matter.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Caian picture Caian  路  3Comments

GerbenRampaart picture GerbenRampaart  路  3Comments

goldenbearkin picture goldenbearkin  路  3Comments

debuggins picture debuggins  路  4Comments

terlar picture terlar  路  3Comments