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

Serverless Error ---- No .serverless/*.zip file found in the package path you provided #4720

Closed
ryub3n opened this issue Feb 5, 2018 · 26 comments

Comments

@ryub3n
Copy link

ryub3n commented Feb 5, 2018

This is a (Bug Report / Feature Proposal)

Description

For bug reports:

  • What went wrong?
    Serverless deploy on AWS CodeBuild using an artifact from s3 caused a Serverless Error No .serverless/*.zip found
  • What did you expect should have happened?
    The CF stack should've been created.
  • What was the config you used?
    My config is big and it deployed the package correctly when I ran serverless deploy from my laptop using AWS profile.
  • What stacktrace or error message from your provider did you see?
    log.txt
    I'm calling serverless deploy in the build phase and it copies my package contents to the .serverless folder and then says it can't find it. I've even listed the contents of the folder and can see it.

My artifact comes from s3 and it's a zip file with the below contents:

  • employee-service-sls-dev
  • employee-service-sls-stg
  • buildspec.yml
  • package.json
  • serverless.config.dev.yml
  • serverless.config.stg.yml
  • serverless.yml
  • sls

I even tried invoking it from post_build with no luck.

Additional Data

  • Serverless Framework Version you're using: 1.26.0
  • Operating System: Ubuntu container with nodejs6.3.1 but the project uses nodejs6.10
  • Stack Trace:
  • Provider Error messages:
@ryub3n
Copy link
Author

ryub3n commented Feb 6, 2018

Seems to be an issue with "package individually: true" which I set only at service level. When I removed it the deployment works fine using CodeBuild but my functions are not packed individually which I need.

@kkesley
Copy link

kkesley commented Apr 17, 2018

Hi @ryub3n ! I recently stuck with the same problem as you! As a work around, I can use package:individually in the service level and use include/exclude in the function level.

@AhiVT
Copy link

AhiVT commented Nov 2, 2018

Just had this happen to me using the latest version of serveless while using the serverless lambda@edge plugin. Setting package:individually at the service level fixed my issue! Thanks @kkesley

@dennisjade
Copy link

After I upgrade to the latest(1.32) I got this same issue and removing the individually: true somewhat fixes the issue. But then I have to specify that in every function

@nkhine
Copy link

nkhine commented Mar 16, 2019

serverless@1.39.0 also breaks this, here is part of my serverless.yml

service: apis

plugins:
  - serverless-parameters
  - serverless-pseudo-parameters
  - serverless-plugin-tracing
  - serverless-iam-roles-per-function
provider:
  name: aws
  runtime: go1.x
  iamRoleStatements:
    - Effect: Allow
      Action:
        - s3:getObject
        - s3:putObject
        - s3:GetObjectVersion
        - s3:ListBucketVersions
        - s3:putBucketPolicy
        - states:startExecution
      Resource: "*"
    - Effect: "Allow" # xray permissions (required)
      Action:
        - "xray:PutTraceSegments"
        - "xray:PutTelemetryRecords"
      Resource:
        - "*"
  stage: ${opt:stage}
  region: ${file(./config.yml):${opt:stage}.REGION}
  tracing: true # enable tracing

package:
  individually: true
  exclude:
    - ./**

functions:
  status:
    handler: bin/status
    description: Status/healthcheck function for API
    memorySize: 128
    package:
      individually: true
      include:
        - ./bin/status
    events:
      - http:
          path: status
          method: get
    timeout: 30

on serverless@1.39.0 i get:

  Serverless Error ---------------------------------------
 
  No status.zip file found in the package path you provided.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           8.11.2
     Serverless Version:     1.39.0
 
Makefile:23: recipe for target 'deploy' failed
make: *** [deploy] Error 1

downgrading to serverless@1.38.0 works

@cs17
Copy link

cs17 commented Mar 17, 2019

serverless@1.39.0 also breaks this, here is part of my serverless.yml

service: apis

plugins:
  - serverless-parameters
  - serverless-pseudo-parameters
  - serverless-plugin-tracing
  - serverless-iam-roles-per-function
provider:
  name: aws
  runtime: go1.x
  iamRoleStatements:
    - Effect: Allow
      Action:
        - s3:getObject
        - s3:putObject
        - s3:GetObjectVersion
        - s3:ListBucketVersions
        - s3:putBucketPolicy
        - states:startExecution
      Resource: "*"
    - Effect: "Allow" # xray permissions (required)
      Action:
        - "xray:PutTraceSegments"
        - "xray:PutTelemetryRecords"
      Resource:
        - "*"
  stage: ${opt:stage}
  region: ${file(./config.yml):${opt:stage}.REGION}
  tracing: true # enable tracing

package:
  individually: true
  exclude:
    - ./**

functions:
  status:
    handler: bin/status
    description: Status/healthcheck function for API
    memorySize: 128
    package:
      individually: true
      include:
        - ./bin/status
    events:
      - http:
          path: status
          method: get
    timeout: 30

on serverless@1.39.0 i get:

  Serverless Error ---------------------------------------
 
  No status.zip file found in the package path you provided.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           8.11.2
     Serverless Version:     1.39.0
 
Makefile:23: recipe for target 'deploy' failed
make: *** [deploy] Error 1

downgrading to serverless@1.38.0 works

Encountered the same problem after v1.39...
Downgrading to v1.38 works for now..

#5931

@brainstorm
Copy link

I can confirm this bug, works fine with 1.38.x and breaks on 1.39.x (see referenced commit/issue right above) :/

@brainstorm
Copy link

Related with #5931

@joshtrotter
Copy link

Same here - encountering this on 1.39.0, works fine on 1.38.0

@aidinkhosrowshahi
Copy link

I have same issue too, it was working before but started failing

Serverless: [AWS s3 200 0.058s 0 retries] getBucketLocation({ Bucket: '*******-artifacts-us-east-1' })
Serverless Error ---------------------------------------
No *****.zip file found in the package path you provided.

Serverless Version: 1.39.0

@shierro
Copy link

shierro commented Mar 18, 2019

same issue with previous 2 comments. it's weird since when I check the .serverless.zip file, it contains the missing zip file mentioned by the error stack trace

@calexandrepcjr
Copy link

Only happens on >1.39.0

@nikita-sheremet-clearscale

Any news? Any workariunds? I have downgraded to 1.38.0 and got same issue :(

@aniljaiswal
Copy link

aniljaiswal commented Oct 15, 2019

It's happening in the version 1.54.0 as well. I am using CodeBuild to package and deploy the functions individually on a service level rather than function level. I can do ls -l in the CodeBuild logs to see the contents but the deployment fails with the error that No function.zip is found in the path package you provided.

Any help is appreciated.

@warapitiya
Copy link

Any workarounds?

@MichaelGoberling
Copy link

This is STILL happening in 1.67.0. I am using Azure Pipelines to try to deploy the functions individually on a service level. I can see the zip files in the .serverless directory in the logs, but the deployment fails with No function.zip is found in the path package you provided.

This is a total deal breaker if you're trying to implement a workflow to pull down the latest staging artifacts and deploy them to production. I can't believe this has zero visibility or responses.

@sschulze
Copy link

Looks like the absolute path to the packaged artifacts is written in the serverless-state.json. Due to this the package isn't portable anymore.
I think the fix should be to write the artifact paths relative to the package-root into the serverless-state.json.
In the case that the user provided an explicit artifact path in serverless.yml I guess it should be copied into the package directory. This way the artifact stays portable and archivable.

As a workaround I'll try to rewrite the serverless-state.json during deployment. But it's rather ugly.... :-(

@jack-morrissey-calabrio
Copy link

Having the exact same problems as @MichaelGoberling and would prefer not to go down the route @sschulze. Any updates now?

@medikoo
Copy link
Contributor

medikoo commented Jun 2, 2020

@aychtang
Copy link

aychtang commented Aug 27, 2020

@medikoo This happens also on my jenkins environment targeting lambda and the original user was using codebuild, I'm not sure if such issue should be pushed to azure specific issues.

@aychtang
Copy link

In other news I moved my service level package properties into the function level and now it works. Not sure what is happening there...

Before (throws missing zip error):

package:
  individually: true
  exclude: - "*/**"

fn:
  package:
    include: []
..

After (now working):

fn:
  package:
    individually: true
    exclude: - "*/**"
    include: []
..

@medikoo
Copy link
Contributor

medikoo commented Aug 27, 2020

@aychtang It's possible that #8130 fixes your case

@VincentHuysmans1
Copy link

VincentHuysmans1 commented Feb 23, 2021

Are there any updates on this ?

Currently facing the same error when deploying individual functions using CodeBuild. Tried above suggestions with no success. Setting package: individually: true on:

  • service level
  • function level
  • service & function level
Your Environment Information -----------------------------
Operating System:          linux
Node Version:              12.16.1
Framework Version:         2.25.2
Plugin Version:            4.4.3
SDK Version:               2.3.2
Components Version:        3.7.0

@medikoo
Copy link
Contributor

medikoo commented Feb 24, 2021

I'm going to close it, as (1) it's a very old issue, reported to very outdated version of a Framework, and many issues have been fixed since then (2) Report is vague, doesn't provide any details on configuration used, from following comments it appears that many plugins are involved, and they can influence the error (in such case bug report should go to problematic plugin repository)

However if you have similar issue, and feel it's a bug in a framework, please open a new bug report respecting all it's remarks. Having all requested information we should be able to coin issue promptly.

@medikoo medikoo closed this as completed Feb 24, 2021
@jplandry908
Copy link

jplandry908 commented May 2, 2021

For anyone else experiencing this issue, I finally identified the root cause and a simple workaround.

In summary, the "artifact" incorrectly has "$CODEBUILD_SRC_DIR" in the value. Also, the srcxxxxxxxxxx number changes between deploy and build, so you can't just do a find/replace for the exact string in DEPLOY since the value is the $CODEBUILD_SRC_DIR that was in BUILD.

For each function in the serverless-state.json, you will see an artifact property that looks similar to:
"artifact": "/codebuild/output/src887072543/src/.serverless/function.zip"
while it should actually look like this:
"artifact": ".serverless/function.zip"

To work around this issue, I simply added the following two lines in my BUILD commands, immediately above the 'serverless deploy ...' statement.

- sed -i 's/\/codebuild\/output//g' artifacts/${!stage}/serverless-state.json
- sed -i 's/\/src.*\//.serverless\//g' artifacts/${!stage}/serverless-state.json

Note: I am using the '${!stage}' value in my code, but this may be different in your implementation - probably $ENV.

This will transform the "/codebuild/output/src887072543/src/.serverless/function.zip" statements to ".serverless/function.zip", allowing the deploy process to find the file without error.

This took me a while to figure out, so I hope it helps others that may be experiencing the same issue.

@vicary
Copy link
Contributor

vicary commented Jul 18, 2022

Thanks @jplandry908, it worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests