Skip to content

[state] Ignore shell mismatch for run #1774

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 1 commit into from
Feb 2, 2024
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
1 change: 1 addition & 0 deletions internal/devbox/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (d *Devbox) RunScript(ctx context.Context, cmdName string, cmdArgs []string
return err
}

lock.SetIgnoreShellMismatch(true)
env, err := d.ensureStateIsUpToDateAndComputeEnv(ctx)
if err != nil {
return err
Expand Down
12 changes: 12 additions & 0 deletions internal/lock/statehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"go.jetpack.io/devbox/internal/cuecfg"
)

var ignoreShellMismatch = false

// stateHashFile is a non-shared lock file that helps track the state of the
// local devbox environment. It contains hashes that may not be the same across
// machines (e.g. manifest hash).
Expand Down Expand Up @@ -46,6 +48,12 @@ func UpdateAndSaveStateHashFile(args UpdateStateHashFileArgs) error {
return cuecfg.WriteFile(stateHashFilePath(args.ProjectDir), newLock)
}

// SetIgnoreShellMismatch is used to disable the shell comparison when checking
// if the state is up to date. This is useful when we don't load shellrc (e.g. running)
func SetIgnoreShellMismatch(ignore bool) {
ignoreShellMismatch = ignore
}

func isStateUpToDate(args UpdateStateHashFileArgs) (bool, error) {
filesystemStateHash, err := readStateHashFile(args.ProjectDir)
if err != nil {
Expand All @@ -56,6 +64,10 @@ func isStateUpToDate(args UpdateStateHashFileArgs) (bool, error) {
return false, err
}

if ignoreShellMismatch {
filesystemStateHash.IsFish = newStateHash.IsFish
}

return *filesystemStateHash == *newStateHash, nil
}

Expand Down