Skip to content

In-project virtualenv not available when added to .gitignore #21855

Closed

Description

Type: Bug

Behaviour

Expected vs. Actual

I use in-project Poetry virtual environment stored in .venv/. The venv loads fine automatically in VSCode.

But if I add .venv/ to .gitignore and restart VSCode, then the venv doesn't load. (It load the system python interpreter instead).
The in-project venv is also no longer available from the "Python: Select Interpreter".

Steps to reproduce:

$ poetry config --list | grep virtualenvs.in-project
virtualenvs.in-project = true

$ poetry init
...
[tool.poetry]
name = "debug_my_venv"
version = "0.1.0"
description = ""
authors = ["..."]
readme = "README.md"
packages = [{include = "debug_my_venv"}]

[tool.poetry.dependencies]
python = "^3.11"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

$ poetry shell
$ poetry install
(.venv/ generated)
$ echo ".venv/" > .gitignore
$ touch foo.py
$ code .

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.4
  • Type of virtual environment used: Global / Poetry (depending on .gitignore...)
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

None

User Settings


languageServer: "Pylance"

Extension version: 2023.14.0
VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2
Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz (12 x 2592)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.79GB (7.18GB free)
Process Argv REDACTED
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-20.04
OS Linux x64 5.15.90.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz (12 x 2592)
Memory (System) 15.62GB (12.93GB free)
VM 0%
Item Value
Remote WSL: Ubuntu-20.04
OS Linux x64 5.15.90.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz (12 x 2592)
Memory (System) 15.62GB (12.93GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627cf:30244335
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
282f8724:30602487
89544117:30613380
2i9eh265:30646982
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
pythoncmvfstrcf:30756944
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
gsofa:30804715
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30812749

Activity

  1. karrtikr commented on Aug 21, 2023

    @karrtikr

    That's interesting, thanks for letting us know about this. We'll try to reproduce this behavior and get back to you soon.

  2. karrtikr commented on Sep 6, 2023

    @karrtikr

    Martin Thøgersen (@th0ger) Unfortunately I'm unable to repro this, but it could due to the fact that we recently fixed discovering venv correctly #21862 in remote scenarios. Can you try VS Code Insiders with pre-release version of the extension and see if it helps?

  3. karrtikr commented on Sep 6, 2023

    @karrtikr
  4. th0ger commented on Sep 6, 2023

    @th0ger
    Author

    Kartik Raj (@karrtikr) which version did you use for testing?

  5. karrtikr commented on Sep 6, 2023

    @karrtikr

    Try the latest pre-release version for VS Code Insiders

  6. th0ger commented on Sep 8, 2023

    @th0ger
    Author

    I'm no longer able to repro on vscode ver 1.81.1...
    That 's odd, because I reproduced it 3-4 times with above steps before I filed this issue.

  7. karrtikr commented on Sep 8, 2023

    @karrtikr

    Good to know, We just made a new VS Code release which likely has something to do with it

  8. locked as resolved and limited conversation to collaborators on Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions