Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init fails in miniconda3 #162

Open
OrangeDog opened this issue Nov 7, 2019 · 7 comments
Open

init fails in miniconda3 #162

OrangeDog opened this issue Nov 7, 2019 · 7 comments

Comments

@OrangeDog
Copy link

This may only be when not run as root, due to lack of sudo.

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/conda/exceptions.py", line 1074, in __call__
        return func(*args, **kwargs)
      File "/opt/conda/lib/python3.7/site-packages/conda/cli/main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "/opt/conda/lib/python3.7/site-packages/conda/cli/conda_argparse.py", line 82, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "/opt/conda/lib/python3.7/site-packages/conda/cli/main_init.py", line 51, in execute
        anaconda_prompt, args.reverse)
      File "/opt/conda/lib/python3.7/site-packages/conda/core/initialize.py", line 120, in initialize
        run_plan_elevated(plan2)
      File "/opt/conda/lib/python3.7/site-packages/conda/core/initialize.py", line 690, in run_plan_elevated
        stdin=stdin
      File "/opt/conda/lib/python3.7/site-packages/conda/gateways/subprocess.py", line 70, in subprocess_call
        p = Popen(encode_arguments(command), cwd=cwd, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env)
      File "/opt/conda/lib/python3.7/subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "/opt/conda/lib/python3.7/subprocess.py", line 1522, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'sudo': 'sudo'

`$ /opt/conda/bin/conda init bash`

  environment variables:
                 CIO_TEST=<not set>
                CLASSPATH=
          CONDA_PKGS_DIRS=/var/lib/jenkins/node/workspace/CSRF_srf-client-python_anaconda@2/pkgs
               CONDA_ROOT=/opt/conda
                     PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
                          :/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : /.condarc
 populated config files : 
          conda version : 4.7.12
    conda-build version : not installed
         python version : 3.7.4.final.0
       virtual packages : 
       base environment : /opt/conda  (read only)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /var/lib/jenkins/node/workspace/CSRF_srf-client-python_anaconda@2/pkgs
       envs directories : /.conda/envs
                          /opt/conda/envs
               platform : linux-64
             user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Linux/3.10.0-1062.4.1.el7.x86_64 debian/10 glibc/2.28
                UID:GID : 1000:1004
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
@OrangeDog
Copy link
Author

If asking why I'm doing conda init, it's because conda activate doesn't work.

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

@soapy1
Copy link

soapy1 commented Nov 7, 2019

Could you provide a full list of commands to reproduce this issue. I can't reproduce it following the commands:

soapy1@:$ docker run -it continuumio/miniconda3:4.7.12-alpine
(base) ff91ef903f17:/$ conda create -n testenv python=2
(base) ff91ef903f17:/$ conda activate testenv
(testenv) ff91ef903f17:/$ # activated environment works

@OrangeDog
Copy link
Author

OrangeDog commented Nov 7, 2019

docker run -it --user 1000:1004 continuumio/miniconda3:latest
conda init bash

and for the activation you were trying to reproduce there

docker run -it --user 1000:1004 continuumio/miniconda3:latest
export CONDA_PKGS_DIRS=/tmp/pkgs
conda create --prefix /tmp/env
conda activate /tmp/envconda

Activation will work if you source /opt/conda/etc/profile.d/conda.sh, but conda init does not.

@soapy1
Copy link

soapy1 commented Nov 7, 2019

This is happening because you are logging in as the wrong user. Do you have a particular reason for this?
https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/debian/Dockerfile#L14-L16
will setup the container to initialize conda upon login if you use the default user

@OrangeDog
Copy link
Author

CI systems generally don’t run containers as root. Nor is it secure practice in general.

Coda generally works as a different user if you give it some writable paths, except for init.

@soapy1
Copy link

soapy1 commented Nov 7, 2019

Right, this conversation is hard to have when it's spanning so many issues and prs, sorry about that.

don’t run containers as root. Nor is it secure practice in general.
Please refer to #161 (comment) regarding why the debian based images are root. The security concerns are why we introduced the slimer/modern alpine images. These work if you do:

$ docker run -it --user 10151 continuumio/miniconda3:4.7.12-alpine
(base) 4eeda7e28fc0:/$ conda create --prefix /tmp/env
(base) 4eeda7e28fc0:/$ conda activate /tmp/env/
(/tmp/env) 4eeda7e28fc0:/$

So, I think we want to be running the alpine images. These don't have bash as pointed out #159. So, running conda build does not always work. I think the conversation #159 (comment) is a slicker idea then adding bash as a package installed in the image. If you need bash you can also install it from the conda-forge channel with conda when you are installing your other build dependencies using conda install conda-forge::bash

@OrangeDog
Copy link
Author

Running the alpine image doesn't help either. The CI system will use its own uid. User permissions are just fundamentally broken in Docker, and you have to do a lot of hoop-jumping if the container is needed to write things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants