Skip to content

Commit

Permalink
Added abs path ref. to devbox binary in wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenari committed Jul 7, 2023
1 parent b100a0b commit bac9aa5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions internal/wrapnix/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ func CreateWrappers(ctx context.Context, devbox devboxer) error {
if err != nil {
return err
}
// get absolute path of devbox binary that the launcher script invokes
// to avoid causing an infinite loop when coreutils gets installed
executablePath, err := os.Executable()
if err != nil {
return err
}

for _, bin := range bins {
if err = createWrapper(&createWrapperArgs{
devboxer: devbox,
BashPath: bashPath,
Command: bin,
ShellEnvHash: shellEnvHash,
destPath: filepath.Join(destPath, filepath.Base(bin)),
devboxer: devbox,
BashPath: bashPath,
Command: bin,
ShellEnvHash: shellEnvHash,
DevboxBinaryPath: executablePath,
destPath: filepath.Join(destPath, filepath.Base(bin)),
}); err != nil {
return errors.WithStack(err)
}
Expand All @@ -67,11 +74,11 @@ func CreateWrappers(ctx context.Context, devbox devboxer) error {

type createWrapperArgs struct {
devboxer
BashPath string
Command string
ShellEnvHash string

destPath string
BashPath string
Command string
ShellEnvHash string
DevboxBinaryPath string
destPath string
}

func createWrapper(args *createWrapperArgs) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/wrapnix/wrapper.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ should be in PATH.

DO_NOT_TRACK=1 can be removed once we optimize segment to queue events.
*/ -}}
eval "$(DO_NOT_TRACK=1 devbox shellenv only-path-without-wrappers)"
eval "$(DO_NOT_TRACK=1 {{ .DevboxBinaryPath }} shellenv only-path-without-wrappers)"

exec {{ .Command }} "$@"

0 comments on commit bac9aa5

Please sign in to comment.