zzet / rbenv

Ansible role for installing rbenv.
https://galaxy.ansible.com/zzet/rbenv/
188 stars 112 forks source link

install gems when rbenv is installed system wide #16

Open khelben opened 9 years ago

khelben commented 9 years ago

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 ...?

zzet commented 9 years ago

Hi @khelben. Yes.

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

vchervanev commented 9 years ago

@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.

blackjid commented 9 years ago

@vchervanev did you find the solution to this?

vchervanev commented 9 years ago

@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.

zzet commented 9 years ago

@vchervanev

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

Like as per user installation? :)

vchervanev commented 9 years ago

@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"

todd-a-jacobs commented 7 years ago

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.