serverless-python-requirements icon indicating copy to clipboard operation
serverless-python-requirements copied to clipboard

Serverless Deploy fails on CircleCI with error "no such file or directory .serverless/requirements"

Open ajb7 opened this issue 5 years ago • 10 comments

I get:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Packaging Python Requirements Lambda Layer...

  Error --------------------------------------------------

  ENOENT: no such file or directory, scandir '.serverless/requirements'

     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 ---------------------------
     OS:                     linux
     Node Version:           6.16.0
     Serverless Version:     1.44.1

error Command failed with exit code 1.

My serverless.yml configs looks like:

custom:
  pythonRequirements:
    dockerizePip: true
    layer: true

functions:
  aFunch:
    handler: someHandler
    events:
      - s3:
          bucket: aBucket
          event: s3:ObjectCreated:*
    layers:
      - {Ref: PythonRequirementsLambdaLayer}

plugins:
  - serverless-python-requirements

Looks like when I zip:true or layer:true ; that is in any way requirements are zipped, the serverless deploy in CircleCI still looks for .serverless/requirements dir and fails to find it.

sls deploy on local works perfectly and so does aws lambda after deployment.

ajb7 avatar Jun 21 '19 15:06 ajb7

Have you declared anything else in your serverless.yml file?

I had the exact same issue (using CircleCI but as a stand alone single layer/no function stack) and had to remove individually: true (left over code from a previous yml file).

I need more context to help you with this.

benmcp avatar Aug 01 '19 23:08 benmcp

Experiencing the same issue with latest serverless version and package option individually: true as well as zip: true in pythonRequirements options. When I disable zipping it's working. Not using CircleCI, just on a Windows machine.

felschr avatar Aug 14 '19 09:08 felschr

we're having something that looks a lot like this as well, only on Jenkins instead of CircleCI.

Serverless: Running ...
Serverless: Packaging service...
Serverless: Packaging Python Requirements Lambda Layer...
 
  Error --------------------------------------------------
 
  ENOENT: no such file or directory, scandir '.serverless/requirements'

our config is

  pythonRequirements:
    slim: true
    useDownloadCache: true
    useStaticCache: true
    noDeploy: []
    layer: true

we're on serverless-python-requirements 4.3.0.

petergaultney avatar Aug 21 '19 21:08 petergaultney

I am using ubuntu, I got a similar issue just now. I think my problem was my setuptools were not setup correctly or not upgraded. Here is what I ran to fix this issue:

sudo apt install python3-widgetsnbextension
sudo apt install python3-testresources
pip install --upgrade --force setuptools --user

I did not change my serverless.yaml, but this is what have configured:

package:
  individually: true

custom:
  pythonRequirements:
    fileName: requirements.txt
    zip: true
    # ...

# ...

eddiecorrigall avatar Oct 23 '19 17:10 eddiecorrigall

Any updates on this? I still get this issue. I was able to get my function to run locally by setting the PYTHONPATH environment variable to each module in the serverless.yml script:

#serverless.yml
provider:
  environment:
    PYTHONPATH: ./function1;./function2;...

However, I don't know if this works in deployment, and I am also required to create a requirements.txt in the serverless.yml directory in order to deploy. To me, it would seem that the

package: 
  individually: 
    true

option is broken somehow, because requirements.txt shouldn't be required in the serverless.yml directory if individual packaging actually worked.

aforslow avatar Jan 31 '20 15:01 aforslow

I believe this is still a problem - we're seeing this same error in GitLab where about half the builds fail. I've left a comment on a similar issue here: ENOENT: no such file or directory, scandir '.serverless/requirement'

thekensman avatar Oct 26 '20 16:10 thekensman

I was having this issue as well. I had included a pyproject.toml file which I'm using to manage black. Serverless was looking at that file instead of requirements.txt.

If you have a pyproject.toml file, you have to include the following to use requirements.txt instead.

  pythonRequirements:
    usePoetry: false

Found this in the documentation

jimbol avatar Dec 01 '20 14:12 jimbol

@jimbol Thanks for this, saved my day 🎉

oba11 avatar Dec 03 '20 14:12 oba11

I had some luck by changing the name of the service in the serverless.yml only alphanumeric characters, which, after some experimentation, was the output of other errors I was having.

DanielWarfield1 avatar Feb 02 '21 20:02 DanielWarfield1

gosh this is terrible, how do I get this to work?

mapattacker avatar Dec 18 '21 02:12 mapattacker