Skip to content

Terminal indicates (base) is activated when other env is selected #20885

Closed as not planned

Description

@karrtikr

WORKAROUND

Run command stated in https://github.com/microsoft/vscode-python/wiki/Activate-Environments-in-Terminal-Using-Environment-Variables#limitations

ISSUE

Testing #20884

image

Hi,

I am testing your test-plan item. Running the script shows indeed that I was using the conda environment I created however inside of the terminal in the parentheses it was still written (base) inside of ('testmarch':conda) or (testmarch) as I would have expected. I was using the inbuilt terminal inside of VS Code, I am on macOS 13.2.1, the output under the python category is in the output view is as follows. Perhaps I have configured incorrectly the test?

Experiment 'pythonTerminalEnvVarActivation' is active
Experiment 'pythonPromptNewToolsExt' is active
> conda info --json
Python interpreter path: /usr/bin/python3
> ~/.conda/bin/conda info --json
> ~/miniconda3/bin/conda info --json
> /usr/bin/python3 -I ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/interpreterInfo.py
> /usr/local/bin/python3 -I ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/interpreterInfo.py
> ~/miniconda3/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/testmarch/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/interpreterInfo.py
Starting Pylance language server.
Python interpreter path: ~/miniconda3/envs/testmarch/bin/python
> conda info --json
shell: zsh
> ~/miniconda3/bin/conda run -n testmarch --no-capture-output python ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/printEnvVariables.py
shell: bash
> ~/.conda/bin/conda info --json
shell: zsh
> ~/miniconda3/bin/conda info --json
shell: zsh
> ~/miniconda3/bin/conda run -n testmarch --no-capture-output python ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.5.10791707/pythonFiles/printEnvVariables.py
shell: zsh
Send text to terminal: /Users/aiday/miniconda3/envs/testmarch/bin/python /Users/aiday/Desktop/TestingFiles/python/script.py
Send text to terminal: /Users/aiday/miniconda3/envs/testmarch/bin/python /Users/aiday/Desktop/TestingFiles/python/script.py

Originally posted by Aiday Marlen Kyzy (@aiday-mar) in #20827 (comment)

Activity

  1. karrtikr commented on Mar 21, 2023

    @karrtikr
    Author

    Hey Aiday Marlen Kyzy (@aiday-mar) , I created a separate issue to investigate. Can you check if the .bashrc file activates the base environment anywhere in it? It would be great if you can send me the .bashrc itself.

  2. bhavyaus commented on Mar 21, 2023

    @bhavyaus

    On Windows and I also only see base activated when other env's are selected.

    image

  3. karrtikr commented on Mar 21, 2023

    @karrtikr
    Author

    Bhavya U (@bhavyaus) I see, can you provide the logs and check the powershell initialization script as suggested in #20885 (comment)?

  4. karrtikr commented on Mar 21, 2023

    @karrtikr
    Author

    Right now there is an issue on VSCode due to which the shell initialization scripts (.bashrc etc.) overrides what is set via VSCode, hence wrong environment can be activated depending on the script.

  5. aiday-mar commented on Mar 22, 2023

    @aiday-mar

    Hey. Typing echo $0 into the terminal showed that I was using zsh. So I add here contents of the .zshrc file on my mac:

    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/Users/aiday/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f "/Users/aiday/miniconda3/etc/profile.d/conda.sh" ]; then
            . "/Users/aiday/miniconda3/etc/profile.d/conda.sh"
        else
            export PATH="/Users/aiday/miniconda3/bin:$PATH"
        fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<
    
  6. karrtikr commented on Mar 22, 2023

    @karrtikr
    Author

    Perfect, thank you. As you can notice base environment is activated due to which this happens #20885 (comment). Try running:

    conda config --set auto_activate_base False
    

    in zsh and restarting the shell, and the issue should disappear.

  7. karrtikr commented on Apr 5, 2023

    @karrtikr
    Author

    Closing as it seems it is expected.

  8. aiday-mar commented on Apr 25, 2023

    @aiday-mar

    Hi Kartik Raj (@karrtikr), my apologies, I just saw your reply to my message. I'll be testing the fix today.

  9. karrtikr commented on Apr 25, 2023

    @karrtikr
    Author

    Aiday Marlen Kyzy (@aiday-mar), as you've already tested #21102, this was tested as part of it. 🙂

  10. locked as resolved and limited conversation to collaborators on May 26, 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