aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.52k stars 1.17k forks source link

Binary execution issues in SAM CLI container due to read-only file system #7469

Open Rommmmm opened 2 months ago

Rommmmm commented 2 months ago

We've encountered a recent change in behavior when executing binaries within the SAM CLI container environment. Previously, we were able to execute a binary from within our project's directory hierarchy without issue. However, we're now experiencing a "read-only file system" error which prevents the binary from running unless it is placed in the /tmp directory.

This change is significantly impacting our development workflow. Moving the binary to /tmp requires us to rebuild the container on every code change, rather than just updating the code and re-invoking the lambda, which was possible before.

Steps to reproduce

  1. Place a binary file in the project directory.
  2. Using the a default template.yaml
  3. Attempt to execute that binary from within a Lambda function running in the SAM CLI container (sam local start-api).
  4. Observe the "read-only file system" error that prevents execution ([Errno 2] No such file or directory:).

Observed result

The binary cannot execute unless it's placed in /tmp, due to the read-only file system error.

Expected result

The binary should be executable within the project directory hierarchy, as it was previously.

Currently our workaround is to create a dockerfile with the binary copied to /tmp and it works but as i wrote each code change requires building and its slowing the work

Thank you for your support.

hnnasit commented 2 months ago

Hi @Rommmmm, thanks for reporting the issue. Could you provide the SAM CLI version with issue and the previous version it was working for? Which runtime is the issue happening for? Can you also provide the Operating System you encountered the issues in?

Rommmmm commented 2 months ago

hey @hnnasit currently im running latest version 1.123.0 of sam cli. unfortunately i dont remember the previous version this was working OS details are: Amazon Linux release 2023.5.20240819 (Amazon Linux) cpe:2.3:o:amazon:amazon_linux:2023 NAME="Amazon Linux" VERSION="2023" ID="amzn" ID_LIKE="fedora" VERSION_ID="2023" PLATFORM_ID="platform:al2023" PRETTY_NAME="Amazon Linux 2023.5.20240819" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023" HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/" DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/" SUPPORT_URL="https://aws.amazon.com/premiumsupport/" BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023" VENDOR_NAME="AWS" VENDOR_URL="https://aws.amazon.com/" SUPPORT_END="2028-03-15" VARIANT_ID="202408281733-2023.214.0" Amazon Linux release 2023.5.20240819 (Amazon Linux) cpe:2.3:o:amazon:amazon_linux:2023

runtime is python 3.12

hnnasit commented 2 months ago

Hi @Rommmmm, was the binary generated using SAM CLI? Could you provide the steps to generate the binary? Also some --debug logs would be useful to see what's happening.