Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Fails when there are multiple -r lines in requirements.txt #863

Description

@kwellman

Are you certain it's a bug?

  • Yes, it looks like a bug

Are you using the latest plugin release?

  • Yes, I'm using the latest plugin release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

The plugin can't handle multiple lines in the requirements.txt file that start with -r. For example:

-r games/requirements.txt
-r app/requirements.txt

My best guess is that the "source" variable is wrongfully overwritten when a line starting with -r is encountered in the following line:

source = path.join(path.dirname(source), req.replace(/^-r\s+/, ''));

Service configuration (serverless.yml) content

N/A

Command name and used flags

serverless deploy

Command output

✖ Stack *****-prod failed to deploy (0s)
Environment: darwin, node 19.4.0, framework 3.38.0 (local) 3.38.0v (global), plugin 7.2.3, SDK 4.5.1
Credentials: Local, "default" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: ENOENT: no such file or directory, open '/Users/kwellman/Projects/*****/games/app/requirements.txt'
    at Object.openSync (node:fs:584:3)
    at Object.readFileSync (node:fs:452:35)
    at getRequirements (/Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:474:6)
    at /Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:484:24
    at Array.reduce (<anonymous>)
    at getRequirements (/Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:478:23)
    at filterRequirementsFile (/Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:501:24)
    at generateRequirementsFile (/Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:90:5)
    at installRequirementsIfNeeded (/Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:642:3)
    at async ServerlessPythonRequirements.installAllRequirements (/Users/kwellman/Projects/*****/node_modules/serverless-python-requirements/lib/pip.js:782:29)

Environment information

Framework Core: 3.38.0 (local) 3.38.0 (global)
Plugin: 7.2.3
SDK: 4.5.1

serverless-python-requirements version 6.1.2

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions