Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The following extensions want to relaunch the terminal to contribute to its environment #24822

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

Open
mecrayavcin opened this issue Feb 8, 2025 · 9 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug needs spike Label for issues that need investigation before they can be worked on.

Comments

@mecrayavcin
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.97.0 (Lastest Version)
  • OS Version: Windows_NT x64 10.0.26100

Image

Steps to Reproduce:

  1. I have anaconda and created 3 env. base, tutorialEnv and playwright.
    In default, Vscode Terminal: Activate Envionment is True so when i get new terminal, my base conda environment is activated,
    But when i try to change env in the same terminal via CTRL + SHIFT + P , new selected environment is never activated in the same terminal and pwsh terminal icon turns to yellow!

"The following extensions want to relaunch the terminal to contribute to its environment"

I want Vscode to activate each environment whatever i select, activate it in the same terminal.
In the pas there was not such a problem.

Could you please fix it in the next update?
Is there any way to fix this?

Thanks

@eleanorjboyd eleanorjboyd transferred this issue from microsoft/vscode Feb 14, 2025
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 14, 2025
@karthiknadig
Copy link
Member

@mecrayavcin Try adding this to your user settings, then re-load VS Code.

"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 14, 2025
@sharpau
Copy link

sharpau commented Feb 14, 2025

I have similar symptoms. The thing I was looking into is that with the Python extension enabled, my terminals all start in AppData instead of the workspace. If I disable Python, they start in the workspace. I also see terminals requesting to restart to activate Python (and if I tell them to, it doesn't work).

I added the user setting above and it solves this problem.

@djalan
Copy link

djalan commented Feb 18, 2025

@mecrayavcin Try adding this to your user settings, then re-load VS Code.

"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]

I am only using one venv and I have a similar error message on every vscode startup. I tried the above solution, but it didn't work.
It's already activated, but Python still wants to relaunch the terminal?

Image

Version: 1.97.2 (user setup)
Commit: e54c774e0add60467559eb0d1e229c6452cf8447
Date: 2025-02-12T23:20:35.343Z
Electron: 32.2.7
ElectronBuildId: 10982180
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.26100

@mecrayavcin
Copy link
Author

"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]

This does not worked for me!

  • When i add this code to Vscode, if i change the environment, there is no pwsh terminal icon error but environment does not change automatically in the same terminal!
  • Also, if add this code, if i change environment, an external cmd popup runs and disappears.

Here is my config

{
    "editor.wordWrap": "on",
    "editor.minimap.enabled": false,
    "editor.guides.bracketPairs": "active",
    "editor.cursorBlinking": "expand",
    "git.autofetch": true,
    "emmet.includeLanguages": {
        "django-html": "html"
    },
    "interactiveWindow.executeWithShiftEnter": true,
    "[python]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
        "source.fixAll": "explicit",
        "source.organizeImports": "explicit"
        },
        "editor.defaultFormatter": "charliermarsh.ruff"
    },
    "notebook.defaultFormatter": "charliermarsh.ruff",
    "notebook.formatOnSave.enabled": true,
    "notebook.formatOnCellExecution": true,
    "notebook.codeActionsOnSave": {
        "notebook.source.fixAll": "explicit",
        "notebook.source.organizeImports": "explicit"
    },
    "terminal.integrated.fontFamily": "FiraCode Nerd Font, monospace",
    "editor.fontFamily": "FiraCode Nerd Font, monospace",
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "terminal.integrated.focusAfterRun": "terminal",    
    "codeium.enableConfig": {
        "*": true,
        "plaintext": true
    },
    "workbench.colorTheme": "Ayu Mirage Bordered",
    "workbench.iconTheme": "ayu"
}

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Mar 20, 2025
@karthiknadig
Copy link
Member

@mecrayavcin Do you have both of these settings on:

Image

and what you shared above is that User settings? Please make sure you have both of the above settings ticked and then add this

"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]

to your User settings.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Mar 20, 2025
@mecrayavcin
Copy link
Author

"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]

Not worked!

Here is what i tried:

  • I tried both conda config --set auto_activate_base false and true

  • Python terminal activate environment is true by default in VScode. Also even added
    "python.terminal.activateEnvironment": true

  • "python.terminal.activateEnvInCurrentTerminal": true,
    "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]

Not worked for me.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Mar 20, 2025
@karthiknadig
Copy link
Member

Try running Python: Clear cache and reload and see if it addressed it.

Before you do anything please try with 2025.3.2025032001 pre-release version of the Python extension. We did a fix specifically with the re-launch terminal.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Mar 20, 2025
@dangotbanned
Copy link

dangotbanned commented Apr 9, 2025

#24822 (comment)
#24822 (comment)

Thanks @karthiknadig!

I fixed this in one of my workspaces a while back.
Couldn't figure out why I still had the issue in others until re-reading your comments

Solution

1. Configure at either user or workspace level

settings.json (User)

{
    "python.experiments.optOutFrom": [
        "pythonTerminalEnvVarActivation"
    ],
    "python.terminal.activateEnvInCurrentTerminal": true,
    "python.terminal.activateEnvironment": true
}

*.code-workspace (Workspace)

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "python.experiments.optOutFrom": [
            "pythonTerminalEnvVarActivation"
        ],
        "python.terminal.activateEnvInCurrentTerminal": true,
        "python.terminal.activateEnvironment": true
    }
}

2. Clear Cache

Ctrl+Shift+P -> Python: Clear Cache and Reload Window

3. Restart VSCode

Opening the terminal now works as expected 🎉

Image

Copy link

github-actions bot commented May 9, 2025

Hey @karthiknadig, this issue might need further attention.

@mecrayavcin, you can help us out by closing this issue if the problem no longer exists, or adding more information.

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug needs spike Label for issues that need investigation before they can be worked on. and removed info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team labels May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug needs spike Label for issues that need investigation before they can be worked on.
Projects
None yet
Development

No branches or pull requests

7 participants