Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Selecting environments when VSCode is launched from an activated terminal #20538

Closed
3 tasks done
karrtikr opened this issue Jan 21, 2023 · 6 comments
Closed
3 tasks done
Labels
testplan-item Test plan item/assignments for upcoming release
Milestone

Comments

@karrtikr
Copy link

karrtikr commented Jan 21, 2023

Refs: #10668

Complexity: 5

Create Issue


Requirements

  • Pre release build of the python extension.
  • VSCode Insiders.
  • Ability to create conda environments.
  • Ability to create virtual environments. For example, use virtualenvwrapper.

Verification

Virtual environments

  • Create a virtual environment:
mkvirtualenv testLaunch
  • Activate it:
workon testLaunch
  • Launch VSCode:

    • Open a folder and launch VSCode:
    code-insiders .
    
    • Launch VSCode without a folder:
    code-insiders
    
    • Any other way it can be launched via terminal.
  • Open a Python file to activate the extension, notice the newly created environment should be selected at startup, and that the logs indicate this:
    image

Non-base conda environments

  • Create conda environment:
conda create -n testLaunch python
  • Activate it:
conda activate testLaunch
  • Launch VSCode.
  • Open a Python file to activate the extension, notice the newly created environment should be selected at startup.

Base conda environments

Context: By default, base conda environments are auto-activated by conda. We only want to select it if it is explicitly activated by user, so we need to check the configuration: https://stackoverflow.com/questions/54429210/how-do-i-prevent-conda-from-activating-the-base-environment-by-default.

Case I:
  • Set environment variable CONDA_AUTO_ACTIVATE_BASE to false.
  • Activate base environment and launch VSCode:
conda activate base
  • Open a Python file to activate the extension, notice the base should be selected at startup.
Case II:
  • Set environment variable CONDA_AUTO_ACTIVATE_BASE to true.
  • Restarting terminal (Powershell on windows) should auto-activate it by default.
  • Activate base environment if need be and launch VSCode.
  • Open a Python file to activate the extension, ensure the base environment is not auto-selected at startup.
Case III:
  • Unset the variable CONDA_AUTO_ACTIVATE_BASE.
  • Check value of conda config:
conda config --get auto_activate_base
  • If the output is set to false, unset it or set the value to true:
conda config --set auto_activate_base true
  • Restarting terminal (Powershell on windows) to auto-activate it, and launch VSCode.
  • Open a Python file to activate the extension, ensure the base environment is not auto-selected at startup.
Case IV:
  • Set config to false:
conda config --set auto_activate_base false
  • Activate base environment and launch VSCode.
  • Open a Python file to activate the extension, a prompt should be shown at startup:
  • Clicking "yes" on which should select the base environment.
@karrtikr karrtikr added the testplan-item Test plan item/assignments for upcoming release label Jan 21, 2023
@rzhao271 rzhao271 added this to the January 2023 milestone Jan 23, 2023
@sandy081
Copy link
Member

@karrtikr Sorry that I do not have any clue to setup following abilities. Is there a doc for setting up them?

  • Ability to create conda environments.
  • Ability to create virtual environments. For example, use virtualenvwrapper.

@karrtikr
Copy link
Author

karrtikr commented Jan 24, 2023

Yes, they just require installing each tool.

Ability to create conda environments.

Install conda via: https://conda.io/projects/conda/en/latest/user-guide/install/index.html. Make sure it's on PATH during installation. Run conda init to initialize the shell if need be.

Ability to create virtual environments. For example, use virtualenvwrapper

Use pip install virtualenvwrapper to install it: https://pypi.org/project/virtualenvwrapper/
On windows see https://pypi.org/project/virtualenvwrapper-win/

@bhavyaus
Copy link

Verified all the cases for Conda and Non Conda cases on Windows.

@andreamah
Copy link

When I set CONDA_AUTO_ACTIVATE_BASE to false, conda still activates base in the terminal (even after restarting). Is this expected?

image

@sandy081 sandy081 removed their assignment Jan 24, 2023
@andreamah
Copy link

Nevermind, I pasted it earlier in my bashrc and it works now 🤔

@andreamah
Copy link

Good work!! Sorry about all of the confusion, lmk if you have questions!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testplan-item Test plan item/assignments for upcoming release
Projects
None yet
Development

No branches or pull requests

5 participants