conda-forge / miniforge

A conda-forge distribution.
https://conda-forge.org/miniforge
Other
6.12k stars 317 forks source link

PowerShell startup produces error #326

Closed phreed closed 2 years ago

phreed commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

With a fresh install of mambaforge on Windows 11. Added the following two profiles to the Windows Terminal.

{
    "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command \"& 'C:\\Users\\feisele\\AppData\\Local\\mambaforge\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\Users\\feisele\\AppData\\Local\\mambaforge' \"",
    "guid": "{c54ac711-9fb8-4f11-89f9-4a81490bf6c0}",
    "hidden": false,
    "icon": "C:\\Users\\feisele\\AppData\\Local\\mambaforge\\Menu\\console_shortcut.ico",
    "name": "PS Mamba",
    "startingDirectory": "%USERPROFILE%"
},
{
    "commandline": "%comspec% \"/K\" \"C:\\Users\\feisele\\AppData\\Local\\mambaforge\\Scripts\\activate.bat\" \"C:\\Users\\feisele\\AppData\\Local\\mambaforge\"",
    "guid": "{5bd2ba02-bd50-4ad7-8461-dc9dca3e3455}",
    "hidden": false,
    "icon": "C:\\Users\\feisele\\AppData\\Local\\mambaforge\\Menu\\console_shortcut.ico",
    "name": "CMD Mamba",
    "startingDirectory": "%USERPROFILE%"
},

The CMD version starts fine, but there is a problem with the Powershell version.

Rename-Item : The item at path 'CondaPromptBackup' already exists.
At C:\Users\feisele\AppData\Local\mambaforge\shell\condabin\Conda.psm1:275 char:9
+         Rename-Item -Path Function:\prompt -NewName CondaPromptBackup ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Rename-Item], PSArgumentException
    + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RenameItemCommand

Making the following change to Conda.psm1:275 mostly prevents the error.

if ($CondaModuleArgs.ChangePs1) {
    # We use the same procedure to nest prompts as we did for nested tab completion.
    if (Test-Path Function:\prompt) {
        Rename-Item -Path Function:\prompt -NewName CondaPromptBackup  -Force 
    } ...

However it does cause the prompt to be slightly broken.

(base) (base) PS C:\Users\feisele>

The environment name is repeated.

Installed packages

conda list
# packages in environment at C:\Users\feisele\AppData\Local\mambaforge:
#
# Name                    Version                   Build  Channel
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
brotlipy                  0.7.0           py39hb82d6ee_1004    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2022.6.15            h5b45459_0    conda-forge
certifi                   2022.6.15        py39hcbf5309_0    conda-forge
cffi                      1.15.0           py39h0878f49_0    conda-forge
chardet                   5.0.0            py39hcbf5309_0    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
colorama                  0.4.5              pyhd8ed1ab_0    conda-forge
conda                     4.12.0           py39hcbf5309_0    conda-forge
conda-build               3.21.9           py39hcbf5309_1    conda-forge
conda-package-handling    1.8.1            py39hb3671d1_1    conda-forge
cryptography              37.0.2           py39h7bc7c5c_0    conda-forge
filelock                  3.7.1              pyhd8ed1ab_0    conda-forge
glob2                     0.7                        py_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
krb5                      1.19.3               h1176d77_0    conda-forge
libarchive                3.5.2                hb45042f_3    conda-forge
libcurl                   7.83.1               h789b8ee_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
liblief                   0.11.5               h0e60522_1    conda-forge
libmamba                  0.22.1               h81a967f_1    conda-forge
libmambapy                0.22.1           py39h4126fcf_1    conda-forge
libsolv                   0.7.22               h7755175_0    conda-forge
libssh2                   1.10.0               h680486a_2    conda-forge
libxml2                   2.9.14               hf5bbc77_0    conda-forge
libzlib                   1.2.12               h8ffe710_1    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
lzo                       2.10              he774522_1000    conda-forge
m2-msys2-runtime          2.5.0.17080.65c939c               3    conda-forge
m2-patch                  2.7.5                         2    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
mamba                     0.22.1           py39hb3d9227_1    conda-forge
markupsafe                2.1.1            py39hb82d6ee_1    conda-forge
menuinst                  1.4.18           py39hcbf5309_1    conda-forge
miniforge_console_shortcut 1.0                  h57928b3_0    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
openssl                   1.1.1p               h8ffe710_0    conda-forge
pip                       22.1.2             pyhd8ed1ab_0    conda-forge
pkginfo                   1.8.3              pyhd8ed1ab_0    conda-forge
psutil                    5.9.1            py39hb82d6ee_0    conda-forge
py-lief                   0.11.5           py39h415ef7b_1    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pycosat                   0.6.3           py39hb82d6ee_1010    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1            py39hcbf5309_5    conda-forge
python                    3.9.13          h9a09f29_0_cpython    conda-forge
python-libarchive-c       4.0              py39hcbf5309_1    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pywin32                   303              py39hb82d6ee_0    conda-forge
pyyaml                    6.0              py39hb82d6ee_4    conda-forge
reproc                    14.2.3               h8ffe710_0    conda-forge
reproc-cpp                14.2.3               h0e60522_0    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
ripgrep                   13.0.0               h7f3b576_2    conda-forge
ruamel_yaml               0.15.80         py39hb82d6ee_1007    conda-forge
setuptools                62.6.0           py39hcbf5309_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sqlite                    3.39.0               h8ffe710_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
tqdm                      4.64.0             pyhd8ed1ab_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
urllib3                   1.26.9             pyhd8ed1ab_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
win_inet_pton             1.1.0            py39hcbf5309_4    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
yaml-cpp                  0.6.3                ha925a31_4    conda-forge
zlib                      1.2.12               h8ffe710_1    conda-forge
zstd                      1.5.2                h6255e5f_1    conda-forge

Environment info

conda info
C:\Users\feisele\AppData\Local\mambaforge\lib\site-packages\requests\__init__.py:102: RequestsDependencyWarning: urllib3 (1.26.9) or chardet (5.0.0)/charset_normalizer (2.0.12) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "

     active environment : base
    active env location : C:\Users\feisele\AppData\Local\mambaforge
            shell level : 1
       user config file : C:\Users\feisele\.condarc
 populated config files : C:\Users\feisele\AppData\Local\mambaforge\.condarc
          conda version : 4.12.0
    conda-build version : 3.21.9
         python version : 3.9.13.final.0
       virtual packages : __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\feisele\AppData\Local\mambaforge  (writable)
      conda av data dir : C:\Users\feisele\AppData\Local\mambaforge\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\feisele\AppData\Local\mambaforge\pkgs
                          C:\Users\feisele\.conda\pkgs
                          C:\Users\feisele\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\feisele\AppData\Local\mambaforge\envs
                          C:\Users\feisele\.conda\envs
                          C:\Users\feisele\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.12.0 requests/2.27.1 CPython/3.9.13 Windows/10 Windows/10.0.22000
          administrator : False
             netrc file : None
           offline mode : False
phreed commented 2 years ago

The problem exists in miniconda3 as well. I have moved the bug to https://github.com/conda/conda/issues/11599