diff --git a/internal/boxcli/shellenv.go b/internal/boxcli/shellenv.go index 2e6fbbd5e47..2ab30e26586 100644 --- a/internal/boxcli/shellenv.go +++ b/internal/boxcli/shellenv.go @@ -94,6 +94,8 @@ func shellEnvFunc(cmd *cobra.Command, flags shellEnvCmdFlags) (string, error) { } func shellEnvOnlyPathWithoutWrappersCmd() *cobra.Command { + // Deprecated: will be removed after devbox 0.7.0 + // Don't add deprecated field to avoid printing anything to stdout command := &cobra.Command{ Use: "only-path-without-wrappers", Hidden: true, diff --git a/internal/wrapnix/wrapper.go b/internal/wrapnix/wrapper.go index 6a3b2b81f2a..8e9ec847958 100644 --- a/internal/wrapnix/wrapper.go +++ b/internal/wrapnix/wrapper.go @@ -55,6 +55,7 @@ func CreateWrappers(ctx context.Context, args CreateWrappersArgs) error { for _, bin := range args.NixBins { if err := createWrapper(&createWrapperArgs{ + WrapperBinPath: destPath, CreateWrappersArgs: args, BashPath: bashPath, Command: bin, @@ -130,6 +131,7 @@ type createWrapperArgs struct { Command string destPath string DevboxSymlinkDir string + WrapperBinPath string // This is the directory where all bin wrappers live } func createWrapper(args *createWrapperArgs) error { diff --git a/internal/wrapnix/wrapper.sh.tmpl b/internal/wrapnix/wrapper.sh.tmpl index b4bb9198915..edcadb6f09f 100644 --- a/internal/wrapnix/wrapper.sh.tmpl +++ b/internal/wrapnix/wrapper.sh.tmpl @@ -25,12 +25,13 @@ eval "$(DO_NOT_TRACK=1 devbox shellenv --preserve-path-stack -c {{ .ProjectDir } fi {{/* -We call only-path-without-wrappers so that we do not invoke other bin-wrappers from +Remove wrapper bin path from PATH so that we don't call more bin-wrappers from this bin-wrapper. Instead, we directly invoke the binary from the nix store, which should be in PATH. -DO_NOT_TRACK=1 can be removed once we optimize segment to queue events. +This is implemented in sed for efficiency. sed is POSIX so we assume it's available. + */ -}} -eval "$(DO_NOT_TRACK=1 devbox shellenv only-path-without-wrappers)" +export PATH=$(echo $PATH | sed -e 's#:{{ .WrapperBinPath }}##' -e 's#{{ .WrapperBinPath }}:##' -e 's#{{ .WrapperBinPath }}##') exec {{ .Command }} "$@"