Gem_package installing the gem for specific user


I am using gem_package to install a gem on the system so that its available for all users. The code is:
gem_package ‘knife-art’ do
clear_sources true
source node[‘knifeart’][‘artifactory_url’]
action :install

The gem gets installed only in the context of current user in this case its root but not available If I switch to any other user on the system. How can I do that?


Well to answer my own question: I used the following:
options “–no-user-install”

This installs the gem into ruby shared specs rather for a specific user. The only caveat here is the installed gem has just rw permisions for the owner and no permissions for group and others which still is a problem.

Is this how its installed and is it advisable to explicitly change the permissions of the installed gem, post install or there is a better way to do things here.

@sbrars You can use option --user-install to install it on user’s space.

I am running the cookbook as root user but want the gem to be installed in some other users profile, does --user-install allows specifying an explicit user.

Just try installing with bash with the following command as a workaround, i will get back you with appropriate solution sometime later.
su - <username> -c "gem install <gem_name>"

Thanks for the reply. I was trying not to resort on execute/bash resource for this but to use the right resource which in this case is gem_package.