diff --git a/recipes/user_install.rb b/recipes/user_install.rb index 96b96aec..9f11c68d 100644 --- a/recipes/user_install.rb +++ b/recipes/user_install.rb @@ -21,6 +21,12 @@ install_rbenv_pkg_prereqs +template "/etc/profile.d/rbenv.sh" do + source "rbenv.sh.erb" + owner "root" + mode "0755" +end + Array(node['rbenv']['user_installs']).each do |rb_user| upgrade_strategy = build_upgrade_strategy(rb_user['upgrade']) git_url = rb_user['git_url'] || node['rbenv']['git_url'] diff --git a/templates/default/rbenv.sh.erb b/templates/default/rbenv.sh.erb index bc5f9b4d..3ccbce05 100644 --- a/templates/default/rbenv.sh.erb +++ b/templates/default/rbenv.sh.erb @@ -4,10 +4,12 @@ # prefer a user rbenv over a system wide install if [[ -s "${HOME}/.rbenv/bin" ]]; then rbenv_root="${HOME}/.rbenv" -else +elif [[ -s "<%= node['rbenv']['root_path'] %>" ]]; then rbenv_root="<%= node['rbenv']['root_path'] %>" export RBENV_ROOT="$rbenv_root" fi -export PATH="${rbenv_root}/bin:$PATH" -eval "$(rbenv init -)" +if [ "$rbenv_root" != "" ]; then + export PATH="${rbenv_root}/bin:$PATH" + eval "$(rbenv init -)" +fi