Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions internal/devbox/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,21 @@ func (d *Devbox) RunScript(ctx context.Context, cmdName string, cmdArgs []string
}

lock.SetIgnoreShellMismatch(true)
env, err := d.ensureStateIsUpToDateAndComputeEnv(ctx)
if err != nil {
return err

var env map[string]string
if d.IsEnvEnabled() {
// Skip ensureStateIsUpToDate if we are already in a shell of this devbox-project
env = envir.PairsToMap(os.Environ())

// This env-var signifies that init-hooks have already run in this shell.
// We set this to ensure that init-hooks do NOT re-run.
env["__DEVBOX_INIT_HOOK_"+d.ProjectDirHash()] = "true"
} else {
var err error
env, err = d.ensureStateIsUpToDateAndComputeEnv(ctx)
if err != nil {
return err
}
}

// Used to determine whether we're inside a shell (e.g. to prevent shell inception)
Expand Down
7 changes: 3 additions & 4 deletions internal/shellgen/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package shellgen

import (
"bytes"
_ "embed"
"fmt"
"log/slog"
"os"
"path/filepath"
"strings"
"text/template"

_ "embed"

"github.com/pkg/errors"
"go.jetpack.io/devbox/internal/boxcli/featureflag"
"go.jetpack.io/devbox/internal/debug"
Expand All @@ -30,9 +29,9 @@ var initHookWrapperTmpl = template.Must(template.New("init-hook-wrapper").Parse(

const scriptsDir = ".devbox/gen/scripts"

// HooksFilename is the name of the file that contains a wrapper of the
// project's init-hooks and plugin hooks
const (
// HooksFilename is the name of the file that contains a wrapper of the
// project's init-hooks and plugin hooks
HooksFilename = ".hooks"
rawHooksFilename = ".raw-hooks"
)
Expand Down