Skip to content

Commit 48dbf54

Browse files
committed
package: hard-code cwd to /tmp to execute brew
If cwd is a directory the brew user can't write to (e.g. if running with bolt as root where the working directory is a private subdirectory under /tmp) brew fails to run. Resolves TheKevJames#101 Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
1 parent 53a5631 commit 48dbf54

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

lib/puppet/provider/package/brew.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ def self.execute(cmd, failonfail = false, combine = false)
4343
if Puppet.features.bundled_environment?
4444
Bundler.with_clean_env do
4545
super(cmd, :uid => uid, :gid => gid, :combine => combine,
46-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
46+
:custom_environment => { 'HOME' => home },
47+
:cwd => '/tmp',
48+
:failonfail => failonfail)
4749
end
4850
else
4951
super(cmd, :uid => uid, :gid => gid, :combine => combine,
50-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
52+
:custom_environment => { 'HOME' => home },
53+
:cwd => '/tmp',
54+
:failonfail => failonfail)
5155
end
5256
end
5357

lib/puppet/provider/package/brewcask.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ def self.execute(cmd, failonfail = false, combine = false)
4343
if Puppet.features.bundled_environment?
4444
Bundler.with_clean_env do
4545
super(cmd, :uid => uid, :gid => gid, :combine => combine,
46-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
46+
:custom_environment => { 'HOME' => home },
47+
:cwd => '/tmp',
48+
:failonfail => failonfail)
4749
end
4850
else
4951
super(cmd, :uid => uid, :gid => gid, :combine => combine,
50-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
52+
:custom_environment => { 'HOME' => home },
53+
:cwd => '/tmp',
54+
:failonfail => failonfail)
5155
end
5256
end
5357

lib/puppet/provider/package/homebrew.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ def self.execute(cmd, failonfail = false, combine = false)
4343
if Puppet.features.bundled_environment?
4444
Bundler.with_clean_env do
4545
super(cmd, :uid => uid, :gid => gid, :combine => combine,
46-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
46+
:custom_environment => { 'HOME' => home },
47+
:cwd => '/tmp',
48+
:failonfail => failonfail)
4749
end
4850
else
4951
super(cmd, :uid => uid, :gid => gid, :combine => combine,
50-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
52+
:custom_environment => { 'HOME' => home },
53+
:cwd => '/tmp',
54+
:failonfail => failonfail)
5155
end
5256
end
5357

lib/puppet/provider/package/tap.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ def self.execute(cmd, failonfail = false, combine = false)
4141
if Puppet.features.bundled_environment?
4242
Bundler.with_clean_env do
4343
super(cmd, :uid => uid, :gid => gid, :combine => combine,
44-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
44+
:custom_environment => { 'HOME' => home },
45+
:cwd => '/tmp',
46+
:failonfail => failonfail)
4547
end
4648
else
4749
super(cmd, :uid => uid, :gid => gid, :combine => combine,
48-
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
50+
:custom_environment => { 'HOME' => home },
51+
:cwd => '/tmp',
52+
:failonfail => failonfail)
4953
end
5054
end
5155

0 commit comments

Comments
 (0)