4

I would like to install pyenv on a shared server (a gitlab runner) so that it is set up for every user. How can ! adapt the official docs to suit this? Two specific questions:

  1. When it says git clone https://github.com/pyenv/pyenv.git ~/.pyenv, since this would save to my home directory, I would imagine it should be saved somewhere else. Where would be the recommended place to clone this?

  2. Where it says to set up the environment variables in .bash_profile, these environmental variables would only affect my user. Where would be the recommendd place to set these variables so that they are set for every user?

TIA

Joey Gough
  • 2,753
  • 2
  • 21
  • 42

1 Answers1

0
# step 1 => clone pyenv repository to shared directory
sudo git clone https://github.com/pyenv/pyenv.git /usr/local/pyenv

# step 2 => add pyenv to the system's PATH
echo 'export PYENV_ROOT="/usr/local/pyenv"' | sudo tee -a /etc/profile.d/pyenv.sh
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' | sudo tee -a /etc/profile.d/pyenv.sh

# step 3 => set up pyenv plugins and initialize pyenv
echo 'eval "$(pyenv init --path)"' | sudo tee -a /etc/profile.d/pyenv.sh
echo 'eval "$(pyenv virtualenv-init -)"' | sudo tee -a /etc/profile.d/pyenv.sh

# step 4 => set permissions
sudo chown -R root:users /usr/local/pyenv
sudo chmod -R g+w /usr/local/pyenv

After following these steps, every user can have access to pyenv

dincer.unal
  • 67
  • 1
  • 2
  • 13