-
Notifications
You must be signed in to change notification settings - Fork 253
[shellenv] add --recompute flag with default=true, while keep global shellenv's recompute flag with default=false #2013
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
70aed6b
to
98f81bb
Compare
…shellenv's recompute flag with default=false
98f81bb
to
82e3259
Compare
@mikeland73 @gcurtis ping |
internal/boxcli/global.go
Outdated
shellEnv := shellEnvCmd() | ||
// For `devbox shellenv` the default value of recompute is true. | ||
// Change the default value to false for `devbox global shellenv` only. | ||
shellEnv.Flag("recompute").DefValue = "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is strictly needed , only for internal consistency. maybe add a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DefValue
modifies the default value printed in the --help
. Without this line, the help for the flag looks like:
% devbox global shellenv --help
...
-r, --recompute Recompute environment if needed (default true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment to explain this need.
internal/boxcli/global.go
Outdated
if err := shellEnv.Flag("recompute").Value.Set("false"); err != nil { | ||
panic(errors.WithStack(err)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add comment:
// This will never panic because internally it just does `strconv.ParseBool("false")` which is always valid
deb89e3
to
91722d8
Compare
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
## Summary This PR continues the work from #2013 to also add the `--recompute` flag option for `devbox run` and `devbox shell`. For some users on bad networks, this can save them annoyance and time for when they _know_ their devbox environment is up-to-date. Fixes #2315 ## How was it tested? This PR affects 3 commands: `run`, `shell` and `shellenv`. 1. For `run`: Added `"hello": "latest",` to devbox.json of this project. ``` devbox run --recompute=false -- echo "hello world" Warning: Your devbox environment may be out of date. Run with --recompute=true to update it. hello world ``` then ``` devbox run -- echo "hello world" Info: Ensuring packages are installed. ✓ Computed the Devbox environment. hello world ``` 2. For `shell`. Ran similar commands as above. 3. For `shellenv`. Followed test plan of #1963. Changed the `.envrc` to be: ``` .envrc @@ -1,7 +1,13 @@ # Automatically sets up your devbox environment whenever you cd into this # directory via our direnv integration: -eval "$(devbox generate direnv --print-envrc)" +#eval "$(devbox generate direnv --print-envrc)" + # output of `devbox generate direnv --print-envrc` to modify it +use_devbox() { + watch_file devbox.json devbox.lock + # eval "$(devbox shellenv --init-hook --install --no-refresh-alias)" + eval "$(devbox shellenv --init-hook --no-refresh-alias --recompute=false)" +} +use devbox # check out https://www.jetify.com/devbox/docs/ide_configuration/direnv/ # for more details ``` Then modified devbox.json and saw the warning get printed. --------- Co-authored-by: savil <>
Summary
Credit to @dax and #1963 for pointing out the need for this, and pioneering this solution.
This PR merely nudges the code to be a bit neater.
How was it tested?
compiled via
devbox run build
, and then: