0

I have installed pyenv, but when I run sudo pip install xx

sudo: pip: command not found 

I know that append /app/pyenv/shims:/app/pyenv/bin(my PYENV_ROOT='/app/pyenv') to secure_path and use

Defaults secure_path += /app/pyenv/shims

in /etc/sudoers.d/pyenv,but failed with

/usr/bin/env: bash: No such file or directory

The output of echo 'echo $PATH' | sudo /bin/bash

/app/pyenv/shims

shows that secure_path just be overwritten.

so how can I append path on the original basis of secure_path in the best way?

Cheney
  • 960
  • 8
  • 23

1 Answers1

1

It seems that have no way to add new_path on original secure_path like Defaults secure_path += /app/pyenv/shims, but there are others way to solve it, without change secure_path now:

  1. sudo -i cmd, it will execute the user's profile,ref from https://unix.stackexchange.com/a/8695 (best)

    echo 'echo $PATH' | sudo -i /bin/bash
    /app/pyenv/shims:/app/pyenv/bin:/app/pyenv/shims:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin  
    
  2. add Defaults exempt_group=user1 ,ref from exempt_group and The exempt_group option in sudo

    exempt_group Users in this group are exempt from password and PATH requirements. The group name specified should not include a % prefix. This is not set by default.

BTW: any know any way to add new_path on original secure_path like Defaults secure_path += /app/pyenv/shims and post it will be appreciated!

Cheney
  • 960
  • 8
  • 23