Skip to content

Commit d000bc6

Browse files
authored
[update] Silence update notice for devbox-global-shellenv and development-devbox (#982)
## Summary For `devbox global shellenv` which may be used in the user's shellrc file, its not ideal to show the update notice everytime the user opens their shell (likely for a non-devbox purpose). For devbox engineers, we need not see the notice everytime we execute a devbox command during development. ## How was it tested? Added `fmt.Fprintf(os.Stderr, "version was checked")` in `boxcli/root.go` just prior to calling `vercheck.BuildVersion`. Then did `devbox global shellenv 1> /dev/null`, and saw that "version was checked" was not printed. As a sanity test, verified that it was printed for `devbox shellenv 1> /dev/null`. Also ran `devbox run build` and saw that the notice was not printed since I'd built the `devbox` originally with the code of this PR.
1 parent d4ee341 commit d000bc6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/boxcli/root.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212

1313
"github.com/spf13/cobra"
14+
"go.jetpack.io/devbox/internal/build"
1415

1516
"go.jetpack.io/devbox/internal/boxcli/midcobra"
1617
"go.jetpack.io/devbox/internal/cloud/openssh/sshshim"
@@ -34,10 +35,19 @@ func RootCmd() *cobra.Command {
3435
Use: "devbox",
3536
Short: "Instant, easy, predictable development environments",
3637
PersistentPreRun: func(cmd *cobra.Command, args []string) {
37-
vercheck.CheckVersion(cmd.ErrOrStderr())
3838
if flags.quiet {
3939
cmd.SetErr(io.Discard)
4040
}
41+
42+
// Skip CheckVersion for `devbox global shellenv` because users will include that
43+
// command in their shellrc files, and we don't want to bother them everytime they
44+
// open their terminals.
45+
//
46+
// Skip CheckVersion for engineers building devbox during development.
47+
if !strings.HasPrefix(cmd.CommandPath(), "devbox global shellenv") &&
48+
!build.IsDev {
49+
vercheck.CheckVersion(cmd.ErrOrStderr())
50+
}
4151
},
4252
RunE: func(cmd *cobra.Command, args []string) error {
4353
return cmd.Help()

0 commit comments

Comments
 (0)