2

Our Linux (Mint) system has 2 admin users - mint & admin. What do we need to do for admin & mint to be able to share gems?

Mint has chef, berkshelf & knife-ec2 installed via bundler in the /home/mint/rbenv/ directory. When switching to admin, these programs are not found:

The program 'knife' is currently not installed. To run 'knife' please ask your administrator to install the package 'chef'

How can both users share the installed packages / programs?

csi
  • 1,535
  • 7
  • 22
  • 42
  • If they have file system access, it should just be exporting the right $GEM_HOME, $GEM_PATH, right? – Aaron Copley Mar 06 '14 at 18:30
  • 2
    For starters, you could try installing the program in another location that the user's home folder. – AWippler Mar 13 '14 at 23:00
  • [Should rbenv be installed system wide or at a user level?](http://stackoverflow.com/questions/16815750/should-rbenv-be-installed-system-wide-or-at-a-user-level) – givanse Nov 15 '14 at 19:57

1 Answers1

1

As @AWippler stated in his comment, install rbenv in a location other than the user's home directory. Install in the /var/opt/rbenv directory.

sudo git clone https://github.com/sstephenson/rbenv.git /var/opt/rbenv

It is important to all adjust user permissions. There are a variety of ways to accomplish this. I add the users to a group called devops.

sudo groupadd devops
sudo usermod -a -G devops username
sudo chgrp -R devops /var/opt/rbenv/
sudo chmod 0775 /var/opt/rbenv
sudo chmod g+s -R /var/opt/rbenv/

Next the $RBENV_PATH needs to be shared as well. Create a rbenv.sh script inside /etc/profile.d.

echo 'export RBENV_ROOT=/var/opt/rbenv' | sudo tee -a '/etc/profile.d/rbenv.sh'
echo 'export PATH=$RBENV_ROOT/bin:$PATH' | sudo tee -a '/etc/profile.d/rbenv.sh'
echo 'eval "$(rbenv init -)"' | sudo tee -a '/etc/profile.d/rbenv.sh'
sudo chgrp devops /etc/profile.d/rbenv.sh
sudo chmod 0660 /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh

Finally, install rbenv and the version that you prefer.

cd /tmp
sudo git clone https://github.com/sstephenson/ruby-build.git
sudo ./ruby-build/install.sh
rbenv install ruby-version
rbenv shell ruby-version
rbenv global ruby-version
rbenv rehash

Note: When installing gems via bundler, be sure to use bundle install --system to share with all users.

csi
  • 1,535
  • 7
  • 22
  • 42