Skip to content

Commit 2292c61

Browse files
committed
fix: replace argv[0] when proxying to binaries
This allows executables that find related files relative to their binary, such as Python, to work.
1 parent da318c6 commit 2292c61

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

bin/hermit.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
env = {
2+
"CGO_ENABLED": "0",
3+
}

env.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,14 @@ func (e *Env) Exec(l *ui.UI, pkg *manifest.Package, binary string, args []string
750750
if filepath.Base(bin) != filepath.Base(binary) {
751751
continue
752752
}
753-
b.Tracef("exec %s", shellquote.Join(append([]string{bin}, args...)...))
753+
argsCopy := make([]string, len(args))
754+
copy(argsCopy, args)
755+
argsCopy[0] = bin
756+
b.Tracef("exec %s", shellquote.Join(argsCopy...))
754757
l.Clear()
755758
timer()
756759

757-
err = syscall.Exec(bin, args, env)
760+
err = syscall.Exec(bin, argsCopy, env)
758761
return errors.Wrapf(err, "%s: failed to execute %q", pkg, bin)
759762
}
760763
return errors.Errorf("%s: could not find binary %q", pkg, binary)

0 commit comments

Comments
 (0)