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

"Error: poetry not found! Install it according to the poetry docs." on Windows 10

Open jorgenfroland opened this issue 4 years ago • 1 comments

Hi,

I'm on Windows10. Serverless environment:

Your Environment Information --------------------------- Operating System: win32 Node Version: 14.15.4 Framework Version: 2.42.0 Plugin Version: 5.1.2 SDK Version: 4.2.2 Components Version: 3.10.0

Version of plugin:

5.1.1

I'm using poetry and according to the documentation, this should work fine. From the doc:

If you include a pyproject.toml and have poetry installed instead of a requirements.txt this will use poetry export --without-hashes -f requirements.txt -o requirements.txt --with-credentials to generate them.

But I ran into this error when I tried to deploy:

PS > serverless deploy Serverless: Generating requirements.txt from pyproject.toml...

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

Error: poetry not found! Install it according to the poetry docs. at ServerlessPythonRequirements.pyprojectTomlToRequirements (C:<path replaced>\node_modules\serverless-python-requirements\lib\poetry.js:34:13)

After some research I found this comment: https://stackoverflow.com/a/54515183/5759828 suggesting to use {shell:true}. As part of my testing I found that the output of spawnSync (line 17 in poetry.js) is:

error: Error: spawnSync poetry ENOENT

I then added shell:true to poetry.js like this:

const res = spawnSync(
    'poetry',
    [
      'export',
      '--without-hashes',
      '-f',
      'requirements.txt',
      '-o',
      'requirements.txt',
      '--with-credentials',
    ],
    {
      cwd: this.servicePath,
      shell: true  <--- added this
    }
  );

and now it works fine.

jorgenfroland avatar May 20 '21 13:05 jorgenfroland

Same here, this issue was solved when I added shell: true as well.

Is there a fix coming for this?

I believe it tries to run poetry in node env instead of shell and does not find the binary that is already in our path for poetry CLI.

NimishVerma avatar Oct 20 '21 02:10 NimishVerma