rbenv icon indicating copy to clipboard operation
rbenv copied to clipboard

install gems when rbenv is installed system wide

Open khelben opened this issue 10 years ago • 7 comments

When I deploy rbenv to be installed system-wide, I cannot install any gems on the installed host.

Do I need to install the gems with sudo gem install ...?

khelben avatar Nov 10 '14 23:11 khelben

Hi @khelben. Yes.

It's normal trouble: https://github.com/sstephenson/rbenv/issues/38 && http://stackoverflow.com/a/18555295

zzet avatar Nov 11 '14 09:11 zzet

@zzet, there is an interesting problem (ubuntu 14.04.1) - when Ansible(1.8.2) runs a SUDO command scripts at profile.d are ignored. As a result env is not prepared and system version of gem is run.

vchervanev avatar Jan 21 '15 07:01 vchervanev

@vchervanev did you find the solution to this?

blackjid avatar Mar 10 '15 19:03 blackjid

@blackjid I'd say Yes. In my case the right way is to use a 3rd party package (e.g. bright-box) since it isn't a dev machine and there is no need to switch between versions. However, if you need RBENV installed - there is a workaround. My initial conclusion was wrong - SUDO is not the reason, but a non-login shell session is.

I moved rbenv's init code to ~/.bashrc and it helped.

vchervanev avatar Mar 11 '15 05:03 vchervanev

@vchervanev

I moved rbenv's init code to ~/.bashrc and it helped.

Like as per user installation? :)

zzet avatar Mar 11 '15 08:03 zzet

@zzet exactly! 8-)

Updated: I had to source env vars at the beginning of .bashrc, I'm not sure if it equals to "per user installation"

vchervanev avatar Mar 11 '15 09:03 vchervanev

When doing a system install, the module really ought to be doing the following:

  1. ensuring the existence of rbenv group using

  2. setting /usr/local/rbenv to be owned by the rbenv_group user

  3. ensuring directories and files have the proper group ownership, e.g.:

    sudo find /usr/local/rbenv -type d -exec chmod g+ws {} +
    sudo find /usr/local/rbenv -type f -exec chmod g+w {} +
    
  4. ensure that the user has the rbenv_group appended to that user's groups list

If you do those things, either within your Ansible scripts or by hand, it works as expected.

todd-a-jacobs avatar Aug 06 '17 01:08 todd-a-jacobs