Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4b6af6

Browse files
author
Andrei Coman
committed
COOK-4183 Set $HOME to new owner as in the pip provider when shelling out
1 parent 02a7bdd commit f4b6af6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

providers/virtualenv.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ def whyrun_supported?
3434
end
3535
Chef::Log.info("Creating virtualenv #{new_resource} at #{new_resource.path}")
3636
interpreter = new_resource.interpreter ? " --python=#{new_resource.interpreter}" : ""
37-
execute "#{virtualenv_cmd}#{interpreter} #{new_resource.options} #{new_resource.path}" do
38-
user new_resource.owner if new_resource.owner
39-
group new_resource.group if new_resource.group
40-
end
37+
options = { :user => new_resource.owner, :group => new_resource.group }
38+
options[:environment] = { 'HOME' => ::File.expand_path("~#{new_resource.owner}") } if new_resource.owner
39+
shell_out!("#{virtualenv_cmd}#{interpreter} #{new_resource.options} #{new_resource.path}", options)
4140
new_resource.updated_by_last_action(true)
4241
end
4342
end

0 commit comments

Comments
 (0)