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:
sam init --app-template hello-world --runtime ruby3.3 --no-tracing --no-application-insights --no-structured-logging --package-type Zip
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)
- OS: Linux 6.10.11-amd64 # 1 SMP PREEMPT_DYNAMIC Debian 6.10.11-1 (2024-09-22) x86_64 GNU/Linux
sam --version: SAM CLI, version 1.129.0
- 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"
]
}
Description:
sam packagecorrectly includes vendored RubyGems if the--template-fileargument is omitted and the default (template.yaml) is used. However, if you specify--template-file template.yamlexplicitly, 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:
sam init --app-template hello-world --runtime ruby3.3 --no-tracing --no-application-insights --no-structured-logging --package-type Zipsam build && sam package --template-file template.yamllogs.txt
Observed result:
If you run
aws s3 cp s3://aws-sam-cli-managed-default-samclisourcebucket-t3venr6as008/530d0f91bb545a27febc4651f7d0e701 packaged.zipto download the package andunzip -l packaged.zipyou can see that only the source files are present:Expected result:
If you omit
--template-file template.yaml, everything works as expected and the uploaded Zip package contains the vendored gems:I don't see anything in the
--helpforsam packagethat 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)
sam --version: SAM CLI, version 1.129.0Paste the output of
sam --infohere