conda-forge / miniforge

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

Miniforge Prompt is broken for username that contains special characters on Windows #484

Closed celliern closed 10 months ago

celliern commented 10 months ago

Solution to issue cannot be found in the documentation.

Issue

That issue concerns windows session with a username that contains special characters (as é, è...). After installation, running the Miniforge Prompt lead to an error

Le chemin d’accès spécifié est introuvable.
(base) C:\Users\Angélina>

And conda cannot be launch.

Running activate.bat the same way as in the shortcut

C:\Users\Angélina\mambaforge\Scripts\activate.bat C:\Users\Angélina\mambaforge

leads to the same error. I suspect an error on the way activate.bat deals with special characters.

We have found a workaround : running

C:\Users\Angélina>C:\Users\Angélina\mambaforge\Scripts\conda init

In an elevated cmd allowed us to use conda (and mamba).

I have checked : it seems that this behavior only occurs un miniforge. A miniconda prompt works out of the box/

Installed packages

C:\Users\Angélina>conda list
EnvironmentLocationNotFound: Not a conda environment: C:\Users\Ang├®lina\mambaforge

Environment info

(base) C:\Users\Angélina>conda info

     active environment : C:\Users\Ang├®lina\mambaforge
    active env location : C:\Users\Ang├®lina\mambaforge
            shell level : 4
       user config file : C:\Users\Angélina\.condarc
 populated config files : C:\Users\Angélina\mambaforge\.condarc
          conda version : 23.3.1
    conda-build version : not installed
         python version : 3.10.12.final.0
       virtual packages : __archspec=1=x86_64
                          __win=0=0
       base environment : C:\Users\Angélina\mambaforge  (writable)
      conda av data dir : C:\Users\Angélina\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\Angélina\mambaforge\pkgs
                          C:\Users\Angélina\.conda\pkgs
                          C:\Users\Angélina\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\Angélina\mambaforge\envs
                          C:\Users\Angélina\.conda\envs
                          C:\Users\Angélina\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/23.3.1 requests/2.31.0 CPython/3.10.12 Windows/10 Windows/10.0.22621
          administrator : False
             netrc file : None
           offline mode : False
hmaarrfk commented 10 months ago

yeah..... this is likely always going to be an issue for you.

I suggest you don't install in this directory, and likely just recreate your user with an ASCII username.

in 2023, I still hit bugs relating to spaces and special characters in files.

celliern commented 10 months ago

Sure, this is for a friend that needed to work with conda, she will be sure to have sanitized username for her office laptop..

As additional info, it seems that all the env-related conda commands are also broken (like conda list). I will check if there is a running issue in the conda repository.

celliern commented 10 months ago

Related issue in conda : https://github.com/conda/conda/issues/10239

hmaarrfk commented 10 months ago

we can probably just refuse to install there at the installation step. that would be a feature to add to constructor

hmaarrfk commented 10 months ago

See: https://github.com/conda/constructor/issues/634

jaimergp commented 10 months ago

The console shortcuts basically run this command:

% cmd /K "${PREFIX}\Scripts\activate.bat" "${PREFIX}"

Where PREFIX is the directory where conda (Miniforge, Miniconda) was installed. If you can run that from a regular CMD instance, then the problem is on menuinst. If it's not, then it's on the system's CMD (sometimes Windows needs to be configured for unicode support on cmd).

You can also try with Powershell, which might be a bit more resilient:

% powershell -ExecutionPolicy ByPass -NoExit -Command "& '${PREFIX}\\shell\\condabin\\conda-hook.ps1' ; conda activate '${PREFIX}'"
ianstokesrees-gamma commented 9 months ago

For what it's worth in corporate settings, where a user's laptop does not belong to them and where they lack admin privs, it can be impossible to fight IT bureaucracy to get user home directory names changed (to remove spaces or special characters). I've just had an incident where some of my colleagues are in exactly this situation and as a result we were unable to get miniforge or mambaforge installed (user home directories were C:\Users\last first).