serverless-ruby-package icon indicating copy to clipboard operation
serverless-ruby-package copied to clipboard

Getting TypeError: Cannot read property 'push' of undefined

Open kamyaarbutt opened this issue 4 years ago • 5 comments

When i add

`plugins:

  • serverless-ruby-package `

i get TypeError: Cannot read property 'push' of undefined

Type Error ----------------------------------------------

TypeError: Cannot read property 'push' of undefined at PackageRubyBundlePlugin.beforePackage (/Users/xxxx/node_modules/serverless-ruby-package/index.js:85:45) at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:576:20) at async PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:634:7) at async Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:327:5) at async /usr/local/lib/node_modules/serverless/scripts/serverless.js:704:9

 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com

Your Environment Information --------------------------- Operating System: darwin Node Version: 16.2.0 Framework Version: 2.43.0 Plugin Version: 5.1.3 SDK Version: 4.2.2 Components Version: 3.10.0

kamyaarbutt avatar May 25 '21 03:05 kamyaarbutt

If you look at the stack trace on master (assuming it matches what you have installed)

The code is:

this.serverless.service.package.include.push("vendor/bundle/bundler/**");

So that is saying that include is not defined

Do you have

package:
  include:
    - handler.rb

In your serverless.yml?

apsoto avatar May 26 '21 22:05 apsoto

My other account locked out so writing from here.

We need to package the functions individually so have the 'include' in each function and not in the main. Still getting the issue.

service: myservice
frameworkVersion: '2'

plugins:
  - serverless-ruby-package


custom:
  rubyPackage:
    alwaysCrossCompileExtensions: true


provider:
  name: aws
  runtime: ruby2.7
  lambdaHashingVersion: 20201221
  profile: demofive

package:
  exclude:
    - '**'

functions:
  hello1:
    handler: handler.hello1
    events:
      - http:
          path: hello1
          method: post
    package:
      include:
        - hello1/**

  hello2:
    handler: handler.hello2
    events:
      - http:
          path: hello2
          method: post
    package:
      include:
        - hello2/**
   

qaswm avatar Jun 15 '21 07:06 qaswm

try putting a top level package/include for an unimportant file just so something is there.

Also, I've never done this per function include, so that might be another complication.

apsoto avatar Jun 15 '21 16:06 apsoto

seems per function include not working.

I added the include in top-level and it worked but now everything is going in every lambda. How to only package only the required items in each lambda.

qaswm avatar Jun 16 '21 16:06 qaswm

I added the include in top-level and it worked but now everything is going in every lambda. How to only package only the required items in each lambda.

I don't think this feature is currently supported. I will try and look into it this weekend, but can't make a guarantee. I'd welcome any contribution if someone wants to make an attempt.

joshuaflanagan avatar Jun 16 '21 16:06 joshuaflanagan