Skip to content

Project-local venv used by default in unrelated folder. #5968

Closed

Description

The extension knows how to find a variety of interpreter environments. This includes venvs in the ".venv" folder directly under the workspace folder, which are project-local. Such an env should not be visible to other workspace folders. I found a case where it gets used by default for a new workspace.

Repro:

  1. create folder: "testing"
  2. run python3 -m venv testing/.venv
  3. run code testing
  4. open a .py file
  5. set the interpreter env to "testing/.venv"
  6. close the folder
  7. create another folder: "eggs"
  8. run code eggs
  9. open a .py file

At that point the extension uses "testing/.venv" as the env. However, the workspace for the "eggs" folder should not know about that interpreter, since it is local to another workspace.

Activity

  1. DonJayamanne commented on Jun 11, 2019

    @DonJayamanne
    • Where is the eggs folder with respect to spam
    • Please paste the contents of your user settings.json and your workspace .vscode/settings.json (interested in seeing the values for python.pythonPath
    • What version of Python do you have installed globally (in your paths)?
    • What versino of Python is in the spam/.venv directory?

    I cannot replicate this at my end (using Mac).

  2. ericsnowcurrently commented on Jun 11, 2019

    @ericsnowcurrently
    Author

    "testing" and "eggs" ended up next to each other in a common parent directory. I have multiple versions of Python installed. "python" is 2.7 and "python3" is 3.6. The venv is 3.7. This is on linux.

    user settings.json:

    {                                                                                                                                                                                                                                                                                                                                                     
        "python.jediEnabled": false,
        "explorer.confirmDelete": false
    }

    The "eggs" settings.json does not exist after step 9, but gets created as soon as I manually set the environment.

    "testing" settings.json:

    {
        "python.testing.unittestArgs": [
            "-v",
            "-s",
            ".",
            "-p",
            "*test*.py"
        ],
        "python.testing.pytestEnabled": true,
        "python.testing.nosetestsEnabled": false,
        "python.testing.unittestEnabled": false,
        "python.testing.pytestArgs": [
            "."
        ],
        "python.pythonPath": ".venv/bin/python"

    Here's how VSCode looks right after step 9 (there's no settings.json yet):
    Screenshot from 2019-06-11 12-47-06

    Here's how it looks when I click on the env in the status bar:
    Screenshot from 2019-06-11 12-49-16

    After selecting one of the available interpreters it creates the appropriate settings.json.

  3. DonJayamanne commented on Jun 11, 2019

    @DonJayamanne

    Looking at the above screenshots, you don't have .venv folder under spam instead it's under a folder named testing.
    Sorry, but please can we try to use same set of data, gets confusing when screenshots refer to one and your notes another.

  4. ericsnowcurrently commented on Jun 12, 2019

    @ericsnowcurrently
    Author

    Sorry, I've corrected it for you.

  5. karrtikr commented on Oct 21, 2021

    @karrtikr

    Fixed in latest extension

  6. locked as resolved and limited conversation to collaborators on Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions