question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

python.poetryPath default setting isn't working on Windows

See original GitHub issue

Environment data

  • VS Code version: 1.14.1
  • Extension version (available under the Extensions sidebar): 2020.1.58038
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): in project .venv
  • Relevant/affected Python packages and their versions: poetry v1.0.2 ‘in the path’
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): both

Expected behaviour

poetry add --dev pylint

Actual behaviour

python -m pip install pylint

Steps to reproduce:

  1. poetry init
  2. poetry install
  3. create a python file
  4. the python extension start and activate the virtualenv as expected
  5. popup that inform no linter found in venv, ask to install
  6. this will install linter without poetry

The default python.poetryPath is set to poetry and this is fine on linux; on windows however, though the executable is in the path and is actually poetry, it is called by the poetry.bat file this means that the right python.poetryPath for windows had to be set to poetry.bat

This isn’t really a big issue, maybe can only be explicit as a settings reference

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
karrtikrcommented, Mar 9, 2021

Spike results

Due to an upstream Windows only bug on node https://github.com/nodejs/node-v0.x-archive/issues/2318 (also see stack overflow answer), child_process.spawn fails to run files without any extension. poetry file inside %USERPROFILE%/.poetry/bin is not an executable, hence spawning it via child_process fails. It is documented shell: true may help us out there, but using it doesn’t return any output for the command for some reason.

The easiest option is just to use child_process.exec instead of child_process.spawn to run poetry, which is provided via https://github.com/microsoft/vscode-python/blob/3a7c11cee5953eb39e666ee441df99d99cda6ac9/src/client/common/process/proc.ts#L60

It works fine both for poetry and poetry.bat files.

1reaction
luabudcommented, Feb 26, 2020

Maybe we shouldn’t let poetryPath point to the bat file.

I think we could prompt an error saying:

“The path to poetry is invalid. Please point it to the executable file.”

What do folks here think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction | Documentation | Poetry - Python dependency ...
Poetry is a tool for dependency management and packaging in Python. ... and the goal is to make it work equally well on...
Read more >
Poetry installed but `poetry: command not found`
When I run this, after shutdown of bash Terminal: export PATH="$HOME/.poetry/bin:$PATH". poetry command is then recognised.
Read more >
Using Python environments in VS Code
Configuring Python Environments in Visual Studio Code. ... by the python.envFile setting. The default value of this setting is ${workspaceFolder}/.env .
Read more >
Dependency Management With Python Poetry
When your Python project relies on external packages, you need to make sure you're using the right version of each package. After an...
Read more >
Configure a Poetry environment | PyCharm Documentation
On macOS and Windows, the installation script will suggest adding the folder with the poetry executable to the PATH variable. Do that by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found