Skip to content

Reconsider changing default value of "python.terminal.activateEnvInCurrentTerminal" to true #19563

Closed

Description

@Gamrix

Environment data

  • Language Server version: 2022.7.40
  • OS and version: darwin x64
  • Python version (and distribution if applicable, e.g. Anaconda): Python 3.8.8, conda 4.13.0
  • python.analysis.indexing: null
  • python.analysis.typeCheckingMode: off

Repro Steps

  1. Have Anaconda, and create an anaconda venv that is not base (in addition to base
  2. Add the following to the workspace settings (get path from activating the env, then typingwhich python)
    {
    "python.defaultInterpreterPath": "/Users/[...]/anaconda3/envs/[your_env]/bin/python",
    }
  3. Restart VSCode to activate Anaconda
  4. Open a terminal window using View: Toggle Terminal, note how conda activate yourenv is run
  5. Close and reopen VSCode.

Expected behavior

When I restart VsCode, the previous environment is restored (or if not possible, the environment that is associated with the defaultInterpreterPath is restored)

Actual behavior

When I restart VSCode, the enviroment is not restored, and instead the base envirnoment is active.

Logs

Activity

  1. heejaechang commented on Jul 25, 2022

    @heejaechang

    it looks like python core ext bug.

  2. karrtikr commented on Jul 29, 2022

    @karrtikr

    Are you saying the environment activated in terminal is not the one you've selected (which is yourenv)? Try setting "python.terminal.activateEnvInCurrentTerminal": true in settings.json. If that doesn't work please provide screenshots to clarify what is expected, and provide the logs as mentioned in the issue template.

    Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    XXX
    

  3. Gamrix commented on Aug 2, 2022

    @Gamrix
    Author

    Ok, adding that setting fixed the issue. Is there a reason why that setting is not the default?

    Also, I don't see it called out anywhere on https://code.visualstudio.com/docs/python/environments

  4. karrtikr commented on Aug 2, 2022

    @karrtikr

    Yep I think it was because some users may not like us altering their current shell automatically, however I think that can be revisited, converting this into a discussion so we can reconsider it.

    Also, I don't see it called out anywhere on https://code.visualstudio.com/docs/python/environments

    It's in https://code.visualstudio.com/docs/python/settings-reference, perhaps we should also mention it in the environment docs if it's off by default. We'll create an issue in the docs https://github.com/microsoft/vscode-docs/issues if need be after the discussion.

  5. changed the title [-]Conda Env not Restored when VSCode is Restarted[/-] [+]Reconsider changing default value of "python.terminal.activateEnvInCurrentTerminal" to `true`[/+] on Aug 2, 2022
  6. locked and limited conversation to collaborators on Aug 2, 2022
  7. converted this issue into a discussion #19610 on Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

info-neededIssue requires more information from postertriage-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