Skip to content

Windows Miniforge Prompt loses system PATH (System32 missing) when using Scripts\activate.bat (mamba activate) #850

Description

@taminaho

Solution to issue cannot be found in the documentation.

  • I checked the documentation.

Issue

Summary

On Windows, launching a Miniforge Prompt via Scripts\activate.bat results in PATH being overwritten to only Miniforge directories, dropping system paths (e.g. %SystemRoot%\System32). As a consequence, standard commands like where (and also code from VS Code) are not found.

Using conda activate (via conda_hook.bat) instead of mamba activate fixes the issue.

How I launch the prompt

Custom shortcut target (similar to the Start Menu Miniforge Prompt):


%windir%\system32\cmd.exe "/K" C:\Users<me>\miniforge3\Scripts\activate.bat C:\Users<me>\miniforge3

Steps to reproduce

  1. Install Miniforge3 on Windows.
  2. Launch Miniforge Prompt (or use the shortcut above).
  3. In the opened cmd.exe (base env), run:

echo %PATH%
echo %SystemRoot%
where where
code --version

Expected behavior

  • PATH should still contain system directories such as:
  • %SystemRoot%\System32
  • %SystemRoot%
  • %SystemRoot%\System32\Wbem
  • etc.
  • where should work.
  • code should work (if VS Code CLI is installed / on PATH in the parent environment).

Actual behavior

  • PATH becomes only Miniforge paths (system paths are missing). Example:

C:\Users<me>\miniforge3;C:\Users<me>\miniforge3\Library\mingw-w64\bin;C:\Users<me>\miniforge3\Library\usr\bin;C:\Users<me>\miniforge3\Library\bin;C:\Users<me>\miniforge3\Scripts;C:\Users<me>\miniforge3\bin;C:\Users<me>\miniforge3\condabin

  • where is not recognized:

'where' is not recognized as an internal or external command,
operable program or batch file.

  • code is also not recognized in this prompt, while it works in cmd or PowerShell (code --version prints a version normally).

Workaround / Fix

Editing C:\Users\<me>\miniforge3\Scripts\activate.bat to use conda activate instead of mamba activate fixes it.

before activate.bat:

@REM Copyright (C) 2021 QuantStack
@REM SPDX-License-Identifier: BSD-3-Clause

@CALL "%~dp0..\condabin\mamba_hook.bat"
mamba activate %*

Current modified activate.bat:

@REM Copyright (C) 2021 QuantStack
@REM SPDX-License-Identifier: BSD-3-Clause

@CALL "%~dp0..\condabin\conda_hook.bat"
conda activate %*

After this change, PATH keeps system entries and both where and code work.

Additional info / suspicion

It looks like the mamba_hook.bat / mamba activate path setup on Windows may be reconstructing PATH without preserving the original process PATH inherited from the parent shell, resulting in system paths being dropped.

Environment

(base) C:\Users<me>>mamba --version
2.4.0
(base) C:\Users<me>>conda --version
conda 25.11.0

Installed packages

# Name                        Version          Build               Channel
archspec                      0.2.5            pyhd8ed1ab_0        conda-forge
boltons                       25.0.0           pyhd8ed1ab_0        conda-forge
brotli-python                 1.2.0            py312hc6d9e41_1     conda-forge
bzip2                         1.0.8            h0ad9c76_8          conda-forge
ca-certificates               2025.11.12       h4c7d964_0          conda-forge
certifi                       2025.11.12       pyhd8ed1ab_0        conda-forge
cffi                          2.0.0            py312he06e257_1     conda-forge
charset-normalizer            3.4.4            pyhd8ed1ab_0        conda-forge
colorama                      0.4.6            pyhd8ed1ab_1        conda-forge
conda                         25.11.0          py312h2e8e312_0     conda-forge
conda-libmamba-solver         25.11.0          pyhd8ed1ab_0        conda-forge
conda-package-handling        2.4.0            pyh7900ff3_2        conda-forge
conda-package-streaming       0.12.0           pyhd8ed1ab_0        conda-forge
cpp-expected                  1.3.1            h477610d_0          conda-forge
distro                        1.9.0            pyhd8ed1ab_1        conda-forge
fmt                           12.0.0           h29169d4_0          conda-forge
frozendict                    2.4.7            py312he06e257_0     conda-forge
h2                            4.3.0            pyhcf101f3_0        conda-forge
hpack                         4.1.0            pyhd8ed1ab_0        conda-forge
hyperframe                    6.1.0            pyhd8ed1ab_0        conda-forge
idna                          3.11             pyhd8ed1ab_0        conda-forge
jsonpatch                     1.33             pyhd8ed1ab_1        conda-forge
jsonpointer                   3.0.0            py312h2e8e312_2     conda-forge
krb5                          1.21.3           hdf4eb48_0          conda-forge
libarchive                    3.8.2            gpl_h26aea39_100    conda-forge
libcurl                       8.17.0           h43ecb02_0          conda-forge
libexpat                      2.7.3            hac47afa_0          conda-forge
libffi                        3.5.2            h52bdfb6_0          conda-forge
libiconv                      1.18             hc1393d2_2          conda-forge
liblzma                       5.8.1            h2466b09_2          conda-forge
libmamba                      2.4.0            h3f46830_1          conda-forge
libmambapy                    2.4.0            py312h6891394_1     conda-forge
libsolv                       0.7.35           h8883371_0          conda-forge
libsqlite                     3.51.1           hf5d6505_0          conda-forge
libssh2                       1.11.1           h9aa295b_0          conda-forge
libxml2                       2.15.1           h5d26750_0          conda-forge
libxml2-16                    2.15.1           h692994f_0          conda-forge
libzlib                       1.3.1            h2466b09_2          conda-forge
lz4-c                         1.10.0           h2466b09_1          conda-forge
lzo                           2.10             h6a83c73_1002       conda-forge
mamba                         2.4.0            h794742e_1          conda-forge
menuinst                      2.4.1            py312hbb81ca0_0     conda-forge
miniforge_console_shortcut    1.0              h57928b3_0          conda-forge
msgpack-python                1.1.2            py312hf90b1b7_1     conda-forge
nlohmann_json-abi             3.12.0           h0f90c79_1          conda-forge
nodejs                        25.2.1           he453025_1          conda-forge
openssl                       3.6.0            h725018a_0          conda-forge
packaging                     25.0             pyh29332c3_1        conda-forge
pip                           25.3             pyh8b19718_0        conda-forge
platformdirs                  4.5.0            pyhcf101f3_0        conda-forge
pluggy                        1.6.0            pyhf9edf01_1        conda-forge
pybind11-abi                  11               hc364b38_1          conda-forge
pycosat                       0.6.6            py312he06e257_3     conda-forge
pycparser                     2.22             pyh29332c3_1        conda-forge
pysocks                       1.7.1            pyh09c184e_7        conda-forge
python                        3.12.12          h0159041_1_cpython  conda-forge
python_abi                    3.12             8_cp312             conda-forge
reproc                        14.2.5.post0     h2466b09_0          conda-forge
reproc-cpp                    14.2.5.post0     he0c23c2_0          conda-forge
requests                      2.32.5           pyhd8ed1ab_0        conda-forge
ruamel.yaml                   0.18.16          py312he06e257_0     conda-forge
ruamel.yaml.clib              0.2.14           py312he06e257_0     conda-forge
setuptools                    80.9.0           pyhff2d567_0        conda-forge
simdjson                      4.2.2            h49e36cd_0          conda-forge
tk                            8.6.13           h2c6b04d_3          conda-forge
tqdm                          4.67.1           pyhd8ed1ab_1        conda-forge
truststore                    0.10.3           pyhe01879c_0        conda-forge
tzdata                        2025b            h78e105d_0          conda-forge
ucrt                          10.0.26100.0     h57928b3_0          conda-forge
urllib3                       2.5.0            pyhd8ed1ab_0        conda-forge
vc                            14.3             h2b53caa_32         conda-forge
vc14_runtime                  14.44.35208      h818238b_32         conda-forge
vcomp14                       14.44.35208      h818238b_32         conda-forge
wheel                         0.45.1           pyhd8ed1ab_1        conda-forge
win_inet_pton                 1.1.0            pyh7428d3b_8        conda-forge
yaml-cpp                      0.8.0            he0c23c2_0          conda-forge
zstandard                     0.25.0           py312he5662c2_1     conda-forge
zstd                          1.5.7            h534d264_6          conda-forge

Environment info

active environment : base
    active env location : C:\Users\<me>\miniforge3
            shell level : 1
       user config file : C:\Users\<me>\.condarc
 populated config files : C:\Users\<me>\miniforge3\.condarc
          conda version : 25.11.0
    conda-build version : not installed
         python version : 3.12.12.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake
                          __conda=25.11.0=0
                          __cuda=0=0
                          __win=10.0.26200=0
       base environment : C:\Users\<me>\miniforge3  (writable)
      conda av data dir : C:\Users\<me>\miniforge3\etc\conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Users\<me>\miniforge3\pkgs
                          C:\Users\<me>\.conda\pkgs
                          C:\Users\<me>\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\<me>\miniforge3\envs
                          C:\Users\<me>\.conda\envs
                          C:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions