zendesk/chef_zendesk_rbenv — pull request #7 by bhouse (2014-10-21 02:39:19+00:00)
Title: [OP-7726] untar ruby version as rbenv user/group

when installing a ruby version from a pre-compiled tarball, untar it as the
rbenv user. This will allow subsequent gem installs to work properly as the
rbenv user

fixes this error:

```
* zendesk_rbenv_ruby[2.1.3] action install[2014-10-21T02:06:23+00:00] INFO: Processing zendesk_rbenv_ruby[2.1.3] action install (/var/chef/cache/cookbooks/zendesk_base/providers/project_scaffold.rb line 60)
(up to date)
* rbenv_gem[gem bundler-1.6.1 for 2.1.3] action install[2014-10-21T02:06:26+00:00] INFO: Processing rbenv_gem[gem bundler-1.6.1 for 2.1.3] action install (/var/chef/cache/cookbooks/zendesk_base/providers/project_scaffold.rb line 62)

================================================================================
Error executing action `install` on resource 'rbenv_gem[gem bundler-1.6.1 for 2.1.3]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/rbenv/versions/2.1.3/bin/gem install bundler -q --no-rdoc --no-ri -v "1.6.1" ----
STDOUT:
STDERR: ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /root/.gem/ruby/2.1.0/cache/bundler-1.6.1.gem
---- End output of /opt/rbenv/versions/2.1.3/bin/gem install bundler -q --no-rdoc --no-ri -v "1.6.1" ----
Ran /opt/rbenv/versions/2.1.3/bin/gem install bundler -q --no-rdoc --no-ri -v "1.6.1" returned 1

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/zendesk_rbenv/libraries/provider_rbenv_rubygems.rb:88:in `install_via_gem_command'
/var/chef/cache/cookbooks/zendesk_rbenv/libraries/provider_rbenv_rubygems.rb:71:in `install_package'

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/zendesk_base/providers/project_scaffold.rb

62: zendesk_rbenv_gem "gem #{name}-#{ver} for #{rubie}" do
63: package_name name
64: ruby_version rubie
65: version ver
66: end
67: end

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/zendesk_base/providers/project_scaffold.rb:62:in `block (3 levels) in class_from_file'

zendesk_rbenv_gem("gem bundler-1.6.1 for 2.1.3") do
provider Chef::Provider::Package::RbenvRubygems
action :install
retries 0
retry_delay 2
guard_interpreter :default
cookbook_name "zendesk_classic_app"
ruby_version "2.1.3"
version "1.6.1"
package_name "bundler"
gem_binary "/opt/rbenv/shims/gem"
end

[2014-10-21T02:06:30+00:00] INFO: Running queued delayed notifications before re-raising exception

================================================================================
Error executing action `create` on resource 'zendesk_base_project_scaffold[zendesk]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
rbenv_gem[gem bundler-1.6.1 for 2.1.3] (/var/chef/cache/cookbooks/zendesk_base/providers/project_scaffold.rb line 62) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/rbenv/versions/2.1.3/bin/gem install bundler -q --no-rdoc --no-ri -v "1.6.1" ----
STDOUT:
STDERR: ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /root/.gem/ruby/2.1.0/cache/bundler-1.6.1.gem
---- End output of /opt/rbenv/versions/2.1.3/bin/gem install bundler -q --no-rdoc --no-ri -v "1.6.1" ----
Ran /opt/rbenv/versions/2.1.3/bin/gem install bundler -q --no-rdoc --no-ri -v "1.6.1" returned 1

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/zendesk_rbenv/libraries/provider_rbenv_rubygems.rb:88:in `install_via_gem_command'
/var/chef/cache/cookbooks/zendesk_rbenv/libraries/provider_rbenv_rubygems.rb:71:in `install_package'

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/zendesk_classic_app/recipes/default.rb

16: zendesk_base_project_scaffold "zendesk" do
17: rubies node["zendesk_classic_app"]["rubies"]
18: gems node["zendesk_classic_app"]["gems"]
19: end
20:

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/zendesk_classic_app/recipes/default.rb:16:in `from_file'

zendesk_base_project_scaffold("zendesk") do
action :create
updated true
updated_by_last_action true
retries 0
retry_delay 2
guard_interpreter :default
cookbook_name "zendesk_classic_app"
recipe_name "default"
rubies ["2.0.0-p353", "2.1.1", "2.1.2", "2.1.3"]
gems {"bundler"=>"1.6.1"}
end
```

`gem install` tries to copy the gem into the following two paths as the rbenv user:
```
- GEM PATHS:
- /opt/rbenv/versions/2.1.3/lib/ruby/gems/2.1.0
- /root/.gem/ruby/2.1.0
```

both these directories are owned by `root`, and the gem install errors out after
trying both options as the `rbenv` user

@zendesk/chef