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

requirements file environment variables in path using -r do not work

Open instil-richard opened this issue 5 years ago • 1 comments

If I have a requirements file including a path to an external requirements file using the -r option such as:

-r ${APP_PATH}/app_requirements.txt

this is the correct syntax for pip but does not work with this plugin. Only absolute paths work with the -r option with this plugin; environment variables in the supplied path are not processed.

Output during a deploy:

  Error: ENOENT: no such file or directory, open '/example/${APP_PATH}/app_requirements.txt'
      at Object.openSync (fs.js:458:3)
      at Object.readFileSync (fs.js:360:35)
      at getRequirements (/example/node_modules/serverless-python-requirements/lib/pip.js:354:6)
      at /example/node_modules/serverless-python-requirements/lib/pip.js:364:24
      at Array.reduce (<anonymous>)
      at getRequirements (/example/node_modules/serverless-python-requirements/lib/pip.js:358:23)
      at filterRequirementsFile (/example/node_modules/serverless-python-requirements/lib/pip.js:381:24)
      at generateRequirementsFile (/example/node_modules/serverless-python-requirements/lib/pip.js:88:5)
      at installRequirementsIfNeeded (/example/node_modules/serverless-python-requirements/lib/pip.js:501:3)
      at ServerlessPythonRequirements.installAllRequirements (/example/node_modules/serverless-python-requirements/lib/pip.js:635:29)

For the use case of nesting external requirements files with the -r option (files which are typically going to be maintained centrally) the processing of an environment variable as part of the path is surely very common, replying only on absolute paths (which one would never want to commit) or relative paths (which vary based on where each engineer's code exists) negates all the benefits of supporting the -r option.

instil-richard avatar Jun 22 '20 17:06 instil-richard

I am having the same issue when I have this in my requirements file.

-r https://raw.githubusercontent.com/snowflakedb/snowflake-connector-python/v2.4.6/tested_requirements/requirements_38.reqs

Here is my output.

Error ---------------------------------------------------
 
  Error: ENOENT: no such file or directory, open '/home/john/PycharmProjects/ml-pipelines/DptSnowTest/https:/raw.githubusercontent.com/snowflakedb/snowflake-connector-python/v2.4.6/tested_requirements/requirements_38.reqs'
      at Object.openSync (node:fs:582:3)
      at Object.readFileSync (node:fs:450:35)
      at getRequirements (/home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:360:6)
      at /home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:370:24
      at Array.reduce (<anonymous>)
      at getRequirements (/home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:364:23)
      at filterRequirementsFile (/home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:387:24)
      at generateRequirementsFile (/home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:92:5)
      at installRequirementsIfNeeded (/home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:521:3)
      at /home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:619:35
      at Array.map (<anonymous>)
      at ServerlessPythonRequirements.installAllRequirements (/home/john/PycharmProjects/ml-pipelines/node_modules/serverless-python-requirements/lib/pip.js:613:8)
      at ServerlessPythonRequirements.tryCatcher (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/home/john/PycharmProjects/ml-pipelines/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (node:internal/timers:464:21)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              16.4.0
     Framework Version:         2.48.0
     Plugin Version:            5.4.2
     SDK Version:               4.2.3

jmcgrath207 avatar Jun 29 '21 13:06 jmcgrath207