Chef-centric way to install ruby gems as a non root user on linux



What’s the resource I should use if I want to install a ruby gem into a non-system ruby installation and do it as a non root user?

In my case I have a user called ubuntu and have installed ruby via rbenv. I want to use the gem executable at~ubuntu/.rbenv/shims/gem and want to install a gem as the ubuntu user.

I can use the execute resource for this but it gets a little tricky to figure out how to write idempotency guards. I would like to reuse existing resources. I see that the package resource has a gem_binary option you can specify, but you can’t specify a user other than root if you are on Linux – only on Mac with homebrew.