conda-forge / miniforge

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

conda init fails on OSX when installed through homebrew #402

Open mjastro opened 1 year ago

mjastro commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

Hi, I was trying to reinstall miniforge for my laptop (Mac, M1 silicon), but I find conda init does not work properly with the latest version.

I wonder whether the latest version has a bug or a problem on my side... the error message is like the following when I do conda init:

`

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/exceptions.py", line 1118, in __call__
    return func(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/cli/main.py", line 69, in main_subshell
    exit_code = do_call(args, p)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/cli/conda_argparse.py", line 91, in do_call
    return getattr(module, func_name)(args, parser)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/cli/main_init.py", line 38, in execute
    return initialize(context.conda_prefix, selected_shells, for_user, args.system,
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/core/initialize.py", line 118, in initialize
    run_plan_elevated(plan2)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/core/initialize.py", line 714, in run_plan_elevated
    result = subprocess_call(
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/conda/gateways/subprocess.py", line 98, in subprocess_call
    stdout, stderr = process.communicate(input=stdin)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/subprocess.py", line 1152, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/subprocess.py", line 1983, in _communicate
    input_view = memoryview(self._input)
TypeError: memoryview: a bytes-like object is required, not 'str'`

Thanks in advance for any help you could offer!

Best, Minju

Installed packages

# packages in environment at /opt/homebrew/Caskroom/miniforge/base:
#
# Name                    Version                   Build  Channel
brotlipy                  0.7.0           py310h8e9501a_1005    conda-forge
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2022.12.7            h4653dfc_0    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py310h2399d43_3    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
conda                     22.11.1         py310hbe9552e_1    conda-forge
conda-package-handling    2.0.2              pyh38be061_0    conda-forge
conda-package-streaming   0.7.0              pyhd8ed1ab_1    conda-forge
cryptography              39.0.0          py310hfc83b78_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
libcxx                    14.0.6               h2692d47_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libsqlite                 3.40.0               h76d750c_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
openssl                   3.0.7                h03a7124_1    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
pycosat                   0.6.4           py310h8e9501a_1    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyopenssl                 23.0.0             pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.10.6          hae75cb6_0_cpython    conda-forge
python_abi                3.10                    3_cp310    conda-forge
readline                  8.1.2                h46ed386_0    conda-forge
requests                  2.28.1             pyhd8ed1ab_1    conda-forge
ruamel.yaml               0.17.21         py310h8e9501a_2    conda-forge
ruamel.yaml.clib          0.2.7           py310h8e9501a_1    conda-forge
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
tqdm                      4.64.1             pyhd8ed1ab_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
urllib3                   1.26.13            pyhd8ed1ab_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
zstandard                 0.19.0          py310had9512b_1    conda-forge
zstd                      1.5.2                h8128057_4    conda-forge

Environment info

active environment : base
    active env location : /opt/homebrew/Caskroom/miniforge/base
            shell level : 1
       user config file : /Users/minle/.condarc
 populated config files : /opt/homebrew/Caskroom/miniforge/base/.condarc
          conda version : 22.11.1
    conda-build version : not installed
         python version : 3.10.6.final.0
       virtual packages : __archspec=1=arm64
                          __osx=12.6=0
                          __unix=0=0
       base environment : /opt/homebrew/Caskroom/miniforge/base  (writable)
      conda av data dir : /opt/homebrew/Caskroom/miniforge/base/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /opt/homebrew/Caskroom/miniforge/base/pkgs
                          /Users/minle/.conda/pkgs
       envs directories : /opt/homebrew/Caskroom/miniforge/base/envs
                          /Users/minle/.conda/envs
               platform : osx-arm64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.10.6 Darwin/21.6.0 OSX/12.6
                UID:GID : 502:20
             netrc file : None
           offline mode : False
drsamchong commented 1 year ago

I may have encountered the same/related issue during Miniforge installation on M1 Mac. When it reaches the prompt to ask whether to run conda init, after a 'yes' reply, it briefly displays a password input, but then fails before any input is given.

...
installation finished
Do you wish the installer to initialize Miniforge3
by running conda init? [yes|no]
[no] >>> yes
Password:
\# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
    Traceback (most recent call last):
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/exceptions.py", line 1129, in __call__
        return func(*args, **kwargs)
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/cli/main.py", line 86, in main_subshell
        exit_code = do_call(args, p)
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/cli/conda_argparse.py", line 93, in do_call
        return getattr(module, func_name)(args, parser)
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/cli/main_init.py", line 50, in execute
        return initialize(context.conda_prefix, selected_shells, for_user, args.system,
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/core/initialize.py", line 119, in initialize
        run_plan_elevated(plan2)
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/core/initialize.py", line 688, in run_plan_elevated
        result = subprocess_call(
      File "/Users/XXXX/miniforge3/lib/python3.10/site-packages/conda/gateways/subprocess.py", line 100, in subprocess_call
        stdout, stderr = process.communicate(input=stdin)
      File "/Users/XXXX/miniforge3/lib/python3.10/subprocess.py", line 1152, in communicate
        stdout, stderr = self._communicate(input, endtime, timeout)
      File "/Users/XXXX/miniforge3/lib/python3.10/subprocess.py", line 1983, in _communicate
        input_view = memoryview(self._input)
    TypeError: memoryview: a bytes-like object is required, not 'str'

`$ /Users/XXXX/miniforge3/bin/conda init zsh`

Environment info:

     active environment : None
       user config file : /Users/XXXX/.condarc
 populated config files : /Users/XXXX/miniforge3/.condarc
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.10.6.final.0
       virtual packages : __osx=13.1=0
                          __unix=0=0
                          __archspec=1=arm64
       base environment : /Users/XXXX/miniforge3  (writable)
      conda av data dir : /Users/XXXX/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/XXXX/miniforge3/pkgs
                          /Users/XXXX/.conda/pkgs
       envs directories : /Users/XXXX/miniforge3/envs
                          /Users/XXXX/.conda/envs
               platform : osx-arm64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.10.6 Darwin/22.2.0 OSX/13.1
                UID:GID : 501:20
             netrc file : None

EDIT: I found a workaround was to run the installation scripts without initializing the shell at the end. There is some info on how to activate the base environment that is printed in response.

After activating base env, running sudo conda init zsh worked. The sudo was required - it failed in the same way as previously without.

hmaarrfk commented 1 year ago

I'm curious to understand what the advantage of installing miniforge through homebrew is? I'm not sure if it is related, but it might be due to that.

hamogu commented 1 year ago

I'm hitting the same problem on linux (bash as shell). miniforge unpacks fine. I tell it it not run conda init and it tells me how to activate conda in that shell. I do that and try conda init but it fails:

(base) no change     /home/submit/hgunther/miniforge3/condabin/conda
no change     /home/submit/hgunther/miniforge3/bin/conda
no change     /home/submit/hgunther/miniforge3/bin/conda-env
no change     /home/submit/hgunther/miniforge3/bin/activate
no change     /home/submit/hgunther/miniforge3/bin/deactivate
no change     /home/submit/hgunther/miniforge3/etc/profile.d/conda.sh
no change     /home/submit/hgunther/miniforge3/etc/fish/conf.d/conda.fish
no change     /home/submit/hgunther/miniforge3/shell/condabin/Conda.psm1
no change     /home/submit/hgunther/miniforge3/shell/condabin/conda-hook.ps1
no change     /home/submit/hgunther/miniforge3/lib/python3.10/site-packages/xontrib/conda.xsh
no change     /home/submit/hgunther/miniforge3/etc/profile.d/conda.csh
modified      /home/submit/hgunther/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

(base) [sudo] password for hgunther: 
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/exceptions.py", line 1129, in __call__
        return func(*args, **kwargs)
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/cli/main.py", line 86, in main_subshell
        exit_code = do_call(args, p)
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/cli/conda_argparse.py", line 93, in do_call
        return getattr(module, func_name)(args, parser)
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/cli/main_init.py", line 50, in execute
        return initialize(context.conda_prefix, selected_shells, for_user, args.system,
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/core/initialize.py", line 119, in initialize
        run_plan_elevated(plan2)
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/core/initialize.py", line 688, in run_plan_elevated
        result = subprocess_call(
      File "/home/submit/hgunther/miniforge3/lib/python3.10/site-packages/conda/gateways/subprocess.py", line 100, in subprocess_call
        stdout, stderr = process.communicate(input=stdin)
      File "/home/submit/hgunther/miniforge3/lib/python3.10/subprocess.py", line 1154, in communicate
        stdout, stderr = self._communicate(input, endtime, timeout)
      File "/home/submit/hgunther/miniforge3/lib/python3.10/subprocess.py", line 1985, in _communicate
        input_view = memoryview(self._input)
    TypeError: memoryview: a bytes-like object is required, not 'str'

`$ /home/submit/hgunther/miniforge3/bin/conda init`

  environment variables:
                 CIO_TEST=<not set>
        CONDA_DEFAULT_ENV=base
                CONDA_EXE=/home/submit/hgunther/miniforge3/bin/conda
             CONDA_PREFIX=/home/submit/hgunther/miniforge3
    CONDA_PROMPT_MODIFIER=(base)
         CONDA_PYTHON_EXE=/home/submit/hgunther/miniforge3/bin/python
               CONDA_ROOT=/home/submit/hgunther/miniforge3
              CONDA_SHLVL=1
           CURL_CA_BUNDLE=<not set>
               MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles
                     PATH=/home/submit/hgunther/miniforge3/bin:/home/submit/hgunther/miniforge3/
                          condabin:/usr/lib64/qt-
                          3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/submit
                          /hgunther/.local/bin:/home/submit/hgunther/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : base
    active env location : /home/submit/hgunther/miniforge3
            shell level : 1
       user config file : /home/submit/hgunther/.condarc
 populated config files : /home/submit/hgunther/miniforge3/.condarc
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.10.8.final.0
       virtual packages : __linux=3.10.0=0
                          __glibc=2.17=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/submit/hgunther/miniforge3  (writable)
      conda av data dir : /home/submit/hgunther/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/submit/hgunther/miniforge3/pkgs
                          /home/submit/hgunther/.conda/pkgs
       envs directories : /home/submit/hgunther/miniforge3/envs
                          /home/submit/hgunther/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.10.8 Linux/3.10.0-1160.45.1.el7.x86_64 centos/7.9.2009 glibc/2.17
                UID:GID : 89328:89328
             netrc file : None
           offline mode : False

An unexpected error has occurred. Conda has prepared the above report.

If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers? [y/N]: 
Timeout reached. No report sent.

(base) 
hamogu commented 1 year ago

I found that due to some setup error, my .bashrc is owned by root (which presumably is why it's asking me for my sudo password). So, I suspect that that's the root cause why it fails, and it then just does not handle that gracefully. I'll report back when I can test that - need the sysadmins to give me access to my own files...

hamogu commented 1 year ago

Making ~/.bashrc writable solved the issue. Since my error looked exactly the same as reported originally on the top of this thread, the same might well be the cause for the issue on Mac.

gerardsimons commented 1 year ago

I had this issue too on Mac M1 on zsh, fish and bash. The sudo workaround worked for me fix the issue

@hamogu: My .bash_profile, fish.config and .zshrc were all owned by me though, not by root, so that was not the issue for me.

hmaarrfk commented 1 year ago

PS. Issues relating to the installation of miniforge are rarely cross platform. Please open a new issue instead of hijacking somebody else's question.

hmaarrfk commented 1 year ago

I'm somewhat tempted to close this issue because unless a homebrew developer can point us to something actionable, you should discuss your specific issues with then.

drsamchong commented 1 year ago

I'm somewhat tempted to close this issue because unless a homebrew developer can point us to something actionable, you should discuss your specific issues with then.

I should add that I did not install miniforge using homebrew, but the scripts available on the repo.

hmaarrfk commented 1 year ago

@drsamchong I think your issue is more similar to what the discussion in https://github.com/conda-forge/miniforge/issues/412 has become.

Again, I do think that installation issues are seldom "the same" even if they appear to be so at first glance.

Please try to follow the troubleshooting steps I've laid out in https://github.com/conda-forge/miniforge/issues/412#issuecomment-1416799692

And open a new issue. Again, not many of us have OSX computers handy, thus it is critical that you give us as much info as possible to help us debug.