diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-04-07 13:23:05 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-04-07 13:23:05 -0700 |
commit | a1eec7e4757f8f328b427f63381d1bda7283b584 (patch) | |
tree | c644124bc50cc633af8999ef269df19fe48906f3 | |
parent | 39ad5e8574783dd9f32cd553a3d5854f844496c1 (diff) | |
download | chef-a1eec7e4757f8f328b427f63381d1bda7283b584.tar.gz |
push ruby_bin first in path for exec'ing bundle intall
-rw-r--r-- | lib/chef/cookbook/gem_installer.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/chef/cookbook/gem_installer.rb b/lib/chef/cookbook/gem_installer.rb index b074890b36..b9bf0ec73f 100644 --- a/lib/chef/cookbook/gem_installer.rb +++ b/lib/chef/cookbook/gem_installer.rb @@ -53,7 +53,8 @@ class Chef tf.puts "gem #{args.map { |i| "'#{i}'" }.join(' ')}" end tf.close - so = shell_out!("bundle install", pwd: dir) + so = shell_out!("bundle install", cwd: dir, env: { "PATH" => path_with_prepended_ruby_bin }) + Chef::Log.info(so.stdout) end end rescue Exception => e @@ -64,6 +65,17 @@ class Chef events.cookbook_gem_finished end + + private + + # path_sanity appends the ruby_bin, but I want the ruby_bin prepended + def path_with_prepended_ruby_bin + env_path = ENV["PATH"].dup || "" + existing_paths = env_path.split(File::PATH_SEPARATOR) + existing_paths.unshift(RbConfig::CONFIG["bindir"]) + env_path = existing_paths.join(File::PATH_SEPARATOR) + env_path.encode("utf-8", invalid: :replace, undef: :replace) + end end end end |