non sudoer conda init bash triggers sudo command

0 views
Skip to first unread message

Julien Cochennec

unread,
Oct 22, 2019, 9:58:53 AM10/22/19
to Anaconda - Public
Hi,
I'm using Ansible to automatically install an application into a conda env.
I created user pmapp.
It has a /home/pmapp directory
I installed Miniconda as root in /opt/miniconda
The ansible process put some files in .ansible directory
I'm running the command "conda init bash" as this user, in its home.
I'm trying to understand this following stack trace.
I see a sudo in it.
Why would conda trigger a sudo command as I'm running it as a non sudoer user?
Did I forgot something?
The goal is to make multi user install of Conda.

fatal: [ansible-dev2]: FAILED! => changed=false
  module_stderr: |-
    Shared connection to ansible-dev2 closed.
  module_stdout: |-
    [sudo] Mot de passe de pmapp:
 
    {"changed": true, "end": "2019-10-22 15:38:02.307227", "stdout": "[y/N]: ",

    "cmd": "/opt/miniconda/bin/conda init bash",
    "failed": true,
    "delta": "0:05:40.400706",
    "stderr": "\n# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<\n\n    Traceback (most recent call last):\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/exceptions.py\", line 1074, in __call__\n        
    return func(*args, **kwargs)\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/cli/main.py\", line 84, in _main\n        
    exit_code = do_call(args, p)\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/cli/conda_argparse.py\", line 82, in do_call\n        
    exit_code = getattr(module, func_name)(args, parser)\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/cli/main_init.py\", line 51, in execute\n        
    anaconda_prompt, args.reverse)\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/core/initialize.py\", line 120, in initialize\n        
    run_plan_elevated(plan2)\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/core/initialize.py\", line 690, in run_plan_elevated\n        
    stdin=stdin\n      
    File \"/opt/miniconda/lib/python3.7/site-packages/conda/gateways/subprocess.py\", line 85, in subprocess_call\n        
    output=formatted_output)\n    
    subprocess.CalledProcessError: Command '['sudo', '/opt/miniconda/bin/python', '-m', 'conda.core.initialize']' returned non-zero exit status
    1.\n\n`$ /opt/miniconda/bin/conda init bash`\n\n  environment variables:\n                
    CIO_TEST=<not set>\n              
    CONDA_ROOT=/opt/miniconda\n                    
    PATH=/sbin:/bin:/usr/sbin:/usr/bin\n      
    REQUESTS_CA_BUNDLE=<not set>\n            
    SSL_CERT_FILE=<not set>\n            
    SUDO_COMMAND=/bin/sh -c echo BECOME-SUCCESS-ykiojdbsynzuedngxuhulitiadpsufpo ;\n                          
    https_proxy=http://proxy.in.***.fr:8080\n                          
    http_proxy=http://proxy.in.***.fr:8080 /usr/bin/python\n
    /var/tmp/ansible-tmp-1571751141.6-36379704861635/AnsiballZ_command.py\n                
    SUDO_GID=1000\n                
    SUDO_UID=1000\n                
    SUDO_USER=ansible\n              
    http_proxy=<set>\n              
    https_proxy=<set>\n\n    
    active environment : None\n      
    user config file : /home/pmapp/.condarc\n
    populated config files : \n          
    conda version : 4.7.12\n    
    conda-build version : not installed\n        
    python version : 3.7.4.final.0\n       virtual packages : \n      
    base environment : /opt/miniconda  (read only)\n          
    channel URLs : https://repo.anaconda.com/pkgs/main/linux-64\n                          
    https://repo.anaconda.com/pkgs/main/noarch\n                          
    https://repo.anaconda.com/pkgs/r/linux-64\n                          
    https://repo.anaconda.com/pkgs/r/noarch\n          
    package cache : /opt/miniconda/pkgs\n                          
    /home/pmapp/.conda/pkgs\n      
    envs directories : /home/pmapp/.conda/envs\n                          
    /opt/miniconda/envs\n              
    platform : linux-64\n            
    user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Linux/3.10.0-957.1.3.el7.x86_64 rhel/7.7 glibc/2.17\n                
    UID:GID : 1001:1001\n            
    netrc file : None\n          
    offline mode : False\n\n\nAn unexpected error has occurred. Conda has prepared the above report.\n\nIf submitted, this report will be used by core maintainers to improve\nfuture releases of conda.\nWould you like conda to send this report to the core maintainers?\n\n\nTimeout reached. No report sent.", "rc": 1, "invocation": {"module_args": {"creates": null, "executable": null, "_uses_shell": true, "strip_empty_ends": true, "_raw_params": "/opt/miniconda/bin/conda init bash", "removes": null, "argv": null, "warn": true, "chdir": "/home/pmapp", "stdin_add_newline": true, "stdin": null}}, "start": "2019-10-22 15:32:21.906521", "warnings": ["Module remote_tmp /home/pmapp/.ansible/tmp did not exist and was created with a mode of 0700, this may cause issues when running as another user. To avoid this, create the remote_tmp dir with the correct permissions manually"], "msg": "non-zero return code"}
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1


Bruno Heremans

unread,
Jan 9, 2020, 7:23:10 AM1/9/20
to Anaconda - Public, trb...@gmail.com
I'm running into the same problem. I'm in an environment where there is no sudo, and hardly anyone has root access.

Why is sudo required for conda init to work? What do you do when sudo is not an option?




On Tuesday, 22 October 2019 15:58:53 UTC+2, Julien Cochennec wrote:
Hi,
I'm using Ansible to automatically install an application into a conda env.

Robert Leach

unread,
Jan 21, 2020, 4:23:40 PM1/21/20
to Anaconda - Public, trb...@gmail.com, kolo...@gmail.com
I also am having the same problem.  I thought conda could work without needing sudo privileges...?  The admins installed conda for me.  I created an environment, but when I go to `conda activate` it, it tells me to `conda init bash`, but doing so asks for `[sudo] password for /username/`.

Bryan Raney

unread,
Apr 26, 2021, 2:06:47 PM4/26/21
to Anaconda - Public, Robert Leach, trb...@gmail.com, kolo...@gmail.com
I have experienced a similar problem with conda requesting sudo access.  I have learned that if the user types Control-C at the sudo password prompt, "conda init bash" successfully modifies the user's .bashrc file anyway.  If they instead do not enter a password and hit Enter enough times where sudo gives up, then we get a similar error stack trace seen by Julien Cochennec.

This is for an Anaconda setup installed as root for all users to use, and a regular user running "conda init bash" as part of setting up their own conda environment.

Reply all
Reply to author
Forward
0 new messages