Skip to content

[bug] Added abs path ref. to devbox binary in wrappers #1260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions internal/wrapnix/wrapper.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DO_NOT_TRACK=1 can be removed once we optimize segment to queue events.

if [[ "${{ .ShellEnvHashKey }}" != "{{ .ShellEnvHash }}" ]] && [[ -z "${{ .ShellEnvHashKey }}_GUARD" ]]; then
export {{ .ShellEnvHashKey }}_GUARD=true
eval "$(DO_NOT_TRACK=1 devbox shellenv -c {{ .ProjectDir }})"
eval "$(DO_NOT_TRACK=1 {{ .DevboxBinaryPath }} shellenv -c {{ .ProjectDir }})"
fi

{{/*
Expand All @@ -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)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
eval "$(DO_NOT_TRACK=1 {{ .DevboxBinaryPath }} shellenv only-path-without-wrappers)"
eval "$(DO_NOT_TRACK=1 '{{ .DevboxBinaryPath }}' shellenv only-path-without-wrappers)"


exec {{ .Command }} "$@"