Skip to content
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

Bug: sam package does not vendor Gems if --template-file is passed #7702

Open
pnc opened this issue Nov 18, 2024 · 1 comment
Open

Bug: sam package does not vendor Gems if --template-file is passed #7702

pnc opened this issue Nov 18, 2024 · 1 comment
Labels

Comments

@pnc
Copy link

pnc commented Nov 18, 2024

Description:

sam package correctly includes vendored RubyGems if the --template-file argument is omitted and the default (template.yaml) is used. However, if you specify --template-file template.yaml explicitly, a package is generated and uploaded, but it does not include vendored gems, leading to runtime failures when gems are missing or do not match the version locked in Gemfile.lock.

Steps to reproduce:

  1. sam init --app-template hello-world --runtime ruby3.3 --no-tracing --no-application-insights --no-structured-logging --package-type Zip
  2. sam build && sam package --template-file template.yaml
    logs.txt

Observed result:

If you run aws s3 cp s3://aws-sam-cli-managed-default-samclisourcebucket-t3venr6as008/530d0f91bb545a27febc4651f7d0e701 packaged.zip to download the package and unzip -l packaged.zip you can see that only the source files are present:

Archive:  packaged.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1126  1980-01-01 00:00   app.rb
       61  1980-01-01 00:00   Gemfile
---------                     -------
     1187                     2 files

Expected result:

If you omit --template-file template.yaml, everything works as expected and the uploaded Zip package contains the vendored gems:

unzip -l packaged-no-template.zip 
Archive:  packaged-no-template.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      352  1980-01-01 00:00   Gemfile.lock
     1126  1980-01-01 00:00   app.rb
       61  1980-01-01 00:00   Gemfile
     1288  1980-01-01 00:00   vendor/bundle/ruby/3.3.0/specifications/httparty-0.22.0.gemspec
     1233  1980-01-01 00:00   vendor/bundle/ruby/3.3.0/specifications/multi_xml-0.7.1.gemspec
     1205  1980-01-01 00:00   vendor/bundle/ruby/3.3.0/specifications/bigdecimal-3.1.8.gemspec
     1201  1980-01-01 00:00   vendor/bundle/ruby/3.3.0/specifications/mini_mime-1.1.5.gemspec
     1811  1980-01-01 00:00   vendor/bundle/ruby/3.3.0/specifications/csv-3.3.0.gemspec
     1060  1980-01-01 00:00   vendor/bundle/ruby/3.3.0/gems/multi_xml-0.7.1/LICENSE.md

I don't see anything in the --help for sam package that would indicate why explicitly specifying the template file would cause such a dramatic difference in behavior. Am I missing something? Thank you!

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

  1. OS: Linux 6.10.11-amd64 # 1 SMP PREEMPT_DYNAMIC Debian 6.10.11-1 (2024-09-22) x86_64 GNU/Linux
  2. sam --version: SAM CLI, version 1.129.0
  3. AWS region: us-east-1

Paste the output of sam --info here

{
  "version": "1.129.0",
  "system": {
    "python": "3.11.10",
    "os": "Linux-6.10.11-amd64-x86_64-with-glibc2.40"
  },
  "additional_dependencies": {
    "docker_engine": "26.1.5+dfsg1",
    "aws_cdk": "Not available",
    "terraform": "1.6.3"
  },
  "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"
  ]
}
@pnc pnc added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Nov 18, 2024
@dkphm
Copy link
Contributor

dkphm commented Nov 19, 2024

Thanks for reporting the issue. I was able to reproduce this bug and we will provide the fix in upcoming release.

@dkphm dkphm added type/bug and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants