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.5k stars 1.17k forks source link

Cannot build generated ruby2.5 Hello World app #838

Closed npc-adrian closed 5 years ago

npc-adrian commented 5 years ago

Description

A basic ruby2.5 app generated using sam init fails to build locally.

Steps to reproduce

  1. sam init --runtime ruby2.5 -n rsam
  2. cd rsam
  3. sam build --use-container

Observed result

$ sam build --use-container --debug
2018-12-07 09:36:33 Using SAM Template at /Users/adrian/code/play/sam/rsam/template.yaml
2018-12-07 09:36:33 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2018-12-07 09:36:33 Changing event name from before-call.apigateway to before-call.api-gateway
2018-12-07 09:36:33 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2018-12-07 09:36:33 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2018-12-07 09:36:33 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2018-12-07 09:36:33 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2018-12-07 09:36:33 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2018-12-07 09:36:33 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2018-12-07 09:36:33 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2018-12-07 09:36:33 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2018-12-07 09:36:33 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2018-12-07 09:36:33 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2018-12-07 09:36:33 Changing event name from before-call.apigateway to before-call.api-gateway
2018-12-07 09:36:33 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2018-12-07 09:36:33 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2018-12-07 09:36:33 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2018-12-07 09:36:33 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2018-12-07 09:36:33 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2018-12-07 09:36:33 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2018-12-07 09:36:33 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2018-12-07 09:36:33 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2018-12-07 09:36:33 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2018-12-07 09:36:33 'build' command is called
2018-12-07 09:36:33 Starting Build inside a container
2018-12-07 09:36:33 Looking for credentials via: env
2018-12-07 09:36:33 Found credentials in environment variables.
2018-12-07 09:36:33 Loading JSON file: /Users/adrian/Library/Python/2.7/lib/python/site-packages/botocore/data/endpoints.json
2018-12-07 09:36:33 Event choose-service-name: calling handler <function handle_service_name_alias at 0x107f811b8>
2018-12-07 09:36:33 Loading JSON file: /Users/adrian/Library/Python/2.7/lib/python/site-packages/botocore/data/serverlessrepo/2017-09-08/service-2.json
2018-12-07 09:36:33 Event creating-client-class.serverlessapplicationrepository: calling handler <function add_generate_presigned_url at 0x107f31f50>
2018-12-07 09:36:33 The s3 config key is not a dictionary type, ignoring its value of: None
2018-12-07 09:36:33 Setting serverlessrepo timeout as (60, 60)
2018-12-07 09:36:33 Loading JSON file: /Users/adrian/Library/Python/2.7/lib/python/site-packages/botocore/data/_retry.json
2018-12-07 09:36:33 Registering retry handlers for service: serverlessrepo
2018-12-07 09:36:33 No Parameters detected in the template
2018-12-07 09:36:33 2 resources found in the template
2018-12-07 09:36:33 Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2018-12-07 09:36:33 Trying paths: ['/Users/adrian/.docker/config.json', '/Users/adrian/.dockercfg']
2018-12-07 09:36:33 Found file at path: /Users/adrian/.docker/config.json
2018-12-07 09:36:33 Found 'auths' section
2018-12-07 09:36:33 Auth data for https://274391695091.dkr.ecr.eu-west-1.amazonaws.com is absent. Client might be using a credentials store instead.
2018-12-07 09:36:33 Auth data for 653789070130.dkr.ecr.eu-west-1.amazonaws.com is absent. Client might be using a credentials store instead.
2018-12-07 09:36:33 Auth data for 274391695091.dkr.ecr.eu-west-1.amazonaws.com is absent. Client might be using a credentials store instead.
2018-12-07 09:36:33 Auth data for https://653789070130.dkr.ecr.eu-west-1.amazonaws.com is absent. Client might be using a credentials store instead.
2018-12-07 09:36:33 Found 'credsStore' section
2018-12-07 09:36:33 Building resource 'HelloWorldFunction'
Build Failed
Error: 'ruby2.5' runtime is not supported

Expected result

Having completed the quick start in Python, I'm attempting to replicate the example app using ruby.

I'd expect the app to build locally.

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

MacOS: 10.14.1
SAM CLI, version 0.8.1
Docker version 18.09.0, build 4d60db4

Add --debug flag to command you are running

jfuss commented 5 years ago

Currently only Python is supported. You can track Ruby update in this issue: #806

Closing as duplicate

npc-adrian commented 5 years ago

Hi, @jfuss how would you suggest I proceed? I'm just trying to get started and the Hello World example doesn't seem to work in Ruby (or go or node - I tried them too). That doesn't seem right to me so I must be missing something.

jfuss commented 5 years ago

All examples have README.md files that you should follow. This will show you the flow that you will need to follow.

npc-adrian commented 5 years ago

Thanks @jfuss. That's solved things for me.

Have you considered updating the Hello World documentation to remove the build step?

My reasons for doing so would be...

jfuss commented 5 years ago

It's not supported for all runtimes (hence this conversation)

Previously (before build), the Quickstart examples where specific to Python with no way to replicate the flow to any other language. This was because you needed to copy your source code into a build folder manually, which was only specific to Python. With the introduction of sam build, this allows us to formulate this workflow into a command that can span each different runtime or language. So the example is support to only work in Python. We could document this but then each release we are tied to a doc update. Instead and since the first example only ever worked for Python, we left it as is and will roll out languages. The command output is also pretty clear on why 'build' didn't work.

As a beginner, it's not really clear to me what the benefit of building locally would be. It seems you don't need it to work locally on an app so I'm guessing it's useful in a more advanced use case I haven't encountered

If you have dependencies, you absolutely need to build, install requirements/dependencies, compile your code to the right architecture and os. You need build if you meet this requirement. sam build gives us a way to make this runtime agnostic.

It appears to break hot reload based on my observations

Hot reloading still works. Previously, you needed to copy your source into a build directory (for Python) or compiling a binary before invoking the function. The way invokes work (sam local [invoke|start-api|start-lambda]) is the template is read, code location is found, and then mounted. This means you can do hot reloading but you may need to run sam build in a different terminal window or copy the edited file(s) or recompile the binary to where the CodeUri points. Invokes never hot reloaded to the affect of build previously but can be solved through sam build --watch command we are looking to add or make the invoke path also build.

npc-adrian commented 5 years ago

Hi @jfuss,

Ok, I finally got the point of SAM build. Thanks for clarifying. Although everything you have said is correct, I still feel that the introductory docs could be improved as they are confusing for beginners.

We could document this but then each release we are tied to a doc update.

An alternative would be to say that support for other runtimes is being rolled and so you should check the readme generated by sam init.

The command output is also pretty clear on why 'build' didn't work.

Do you mean Error: 'ruby2.5' runtime is not supported? Yes, that's right but it doesn't give a novice any guidance on how to resolve the issue.

Referring the me to the generated readme would have helped in this case too.

Hot reloading still works...but you may need to run sam build

Ah ok, that would explain my issue. It's obvious with hindsight but it wasn't at the time.