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

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

Open kwellman opened this issue 5 months ago • 0 comments

Are you certain it's a bug?

  • [x] Yes, it looks like a bug

Are you using the latest plugin release?

  • [x] Yes, I'm using the latest plugin release

Is there an existing issue for this?

  • [x] 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: https://github.com/serverless/serverless-python-requirements/blob/b58ce60097717c369eea9f1e807a1374c7e4937f/lib/pip.js#L483

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

kwellman avatar Aug 25 '25 20:08 kwellman