Skip to content

vscode指定环境时默认运行的不存在的文件 #834

@bl201112

Description

@bl201112

Type: Bug

Bug Report: VS Code PowerShell Terminal Persistently Executes a Ghost Conda Command After Uninstall

Subject: VS Code Terminal (PowerShell 7) Launches with Incorrect, Ghost Conda Command After Full Anaconda Uninstall and Clean Reinstall

Environment

  • VS Code Version: [Please insert your VS Code version, e.g., 1.93.0]
  • Operating System: [Please insert your Windows version, e.g., Windows 11 Pro 23H2]
  • Integrated Terminal: PowerShell 7.5.2
  • Conda Distribution: A previous installation of Anaconda3 was fully uninstalled. A fresh installation of Miniconda3 is now the active version.
  • Relevant VS Code Extensions:
    • Microsoft Python Extension (ms-python.python)
    • [Please list any other relevant extensions, e.g., PowerShell extension]

Problem Description

When a new PowerShell 7 integrated terminal is opened in VS Code, it immediately and automatically attempts to execute a command that appears to be a leftover artifact from a previous, now-uninstalled Anaconda3 installation. This command fails because the specified file path no longer exists. This issue prevents the proper initialization of the current, correct Miniconda environment and clutters every new terminal session with error messages.

Expected Behavior

The PowerShell 7 terminal should launch cleanly without errors. After a successful conda init powershell with the new Miniconda installation, the terminal prompt should correctly display the (base) environment without any preceding error messages.

Actual Behavior

The following command is executed automatically upon terminal launch, followed by two distinct errors:

(base) PS D:\Code\lbfsi-taichi-main> (& C:\Users\Baolin\anaconda3\Library\shell\condabin\conda-hook.ps1) ; (conda activate C:\Users\Baolin\miniconda3\envs\compute)

# Error 1: File not found
&: The term 'C:\Users\Baolin\anaconda3\Library\shell\condabin\conda-hook.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

# Error 2: Consequence of the first error
CondaError: Run 'conda init' before 'conda activate'
This clearly shows the system is trying to use a hook from a non-existent anaconda3 installation to activate an environment from the existing miniconda3 installation.

Troubleshooting Steps Already Taken (Exhaustive List)
This issue has proven to be extremely persistent. The following standard and advanced troubleshooting steps have all been performed without resolving the problem:

Conda Initialization:

Ran conda init powershell multiple times.

Ran conda init --reverse --all to completely remove all shell hooks, followed by conda init powershell again.

PowerShell Profiles:

Checked the user-specific profile by running notepad $PROFILE. The file was confirmed to be non-existent or blank.

Checked the system-wide profile by running notepad $PROFILE.AllUsersAllHosts (with Admin rights). The file was confirmed to be non-existent or blank. All four potential profile locations are clean of any Conda configuration.

VS Code Configuration:

Checked the User settings.json file for any terminal.integrated.profiles.windows or terminal.integrated.shellArgs.windows settings that could inject the command. None were found.

Checked for a project-specific Workspace setting (.vscode/settings.json) that could be overriding the user settings. None were found.

Performed a full reset of VS Code's user configuration by renaming the %APPDATA%\Code folder to Code.bak and restarting VS Code to generate a fresh configuration. The issue still recurred after running conda init on the fresh installation.

Full Reinstallation:

Backed up Conda environments using conda env export.

Uninstalled both Anaconda3 and Miniconda3 via Windows "Add or Remove Programs".

Manually deleted all leftover folders (C:\Users\Baolin\anaconda3, C:\Users\Baolin\miniconda3).

Manually cleaned the system and user Path environment variables of any Anaconda/Miniconda entries.

Rebooted the PC.

Performed a fresh, clean installation of the latest Miniconda3.

Ran conda init powershell from the new installation.

Even after this complete cleanup and reinstallation process, the ghost command pointing to the old anaconda3 path still executes in every new VS Code terminal. This suggests the configuration is being stored in a non-standard location that is read by VS Code or its terminal launcher, but is not being cleared by any of the standard methods.

Any assistance in identifying this hidden configuration source would be greatly appreciated. Thank you.

VS Code version: Code 1.103.2 (6f17636121051a53c88d3e605c491d22af2ba755, 2025-08-20T16:45:34.255Z)
OS version: Windows_NT x64 10.0.19045
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz (8 x 3000)|
|GPU Status|2d_canvas: enabled<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>trees_in_viz: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled<br>webnn: disabled_off|
|Load (avg)|undefined|
|Memory (System)|31.78GB (15.20GB free)|
|Process Argv|--crash-reporter-id 96881b54-a5a6-4456-b537-8fce53c5e65b|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (41)</summary>

Extension|Author (truncated)|Version
---|---|---
better-comments|aar|3.0.2
codesnap|adp|1.3.4
Bookmarks|ale|13.5.0
markdown-mermaid|bie|1.28.0
path-intellisense|chr|2.10.0
vscode-notes|dio|2.0.0
docker|doc|0.16.0
copilot|Git|1.364.0
copilot-chat|Git|0.30.3
latex-workshop|Jam|10.10.2
vsc-python-indent|Kev|1.21.0
vscode-gutter-preview|kis|0.32.2
vscode-containers|ms-|2.1.0
vscode-language-pack-zh-hans|MS-|1.103.2025081309
debugpy|ms-|2025.10.0
python|ms-|2025.12.0
vscode-pylance|ms-|2025.7.1
vscode-python-envs|ms-|1.2.0
datawrangler|ms-|1.22.0
jupyter|ms-|2025.7.0
jupyter-keymap|ms-|1.1.2
jupyter-renderers|ms-|1.3.0
vscode-jupyter-cell-tags|ms-|0.1.9
vscode-jupyter-slideshow|ms-|0.1.6
remote-containers|ms-|0.422.1
remote-ssh|ms-|0.120.0
remote-ssh-edit|ms-|0.87.0
remote-wsl|ms-|0.99.0
cmake-tools|ms-|1.21.36
cpptools|ms-|1.26.3
cpptools-extension-pack|ms-|1.3.1
makefile-tools|ms-|0.12.17
remote-explorer|ms-|0.5.0
material-icon-theme|PKi|5.26.0
markdown-preview-enhanced|shd|0.8.19
pdf|tom|1.2.2
cmake|twx|0.0.17
errorlens|use|3.26.0
mplstyle|yy0|1.14.4
markdown-all-in-one|yzh|3.6.3
material-theme|zhu|3.19.0

(3 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

vsliv368:30146709
vswsl492:30256859
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
747dc170:31275177
aj953862:31281341
nesew2to5:31336538
agentclaude:31350858
82j33506:31327384
nes-set-on:31351930
onetestforazureexpcf:31335614
63221493:31336333
envsactivate1:31353494
0927b901:31350571
4gdec884:31348710
custommodel2t:31371781
45650338:31358607
0cj2b977:31352657
justeven_python:31371804
0574c672:31362109
pylancealldocsf:31371773
cloudbuttonc:31374191
retryenabled:31370050
3efgi100_wstrepl:31374188


</details>

<!-- generated by issue reporter -->

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions