Support setting the --config flag via the DEVBOX_CONFIG env var#2838
Open
mikeland73 wants to merge 4 commits into
Open
Support setting the --config flag via the DEVBOX_CONFIG env var#2838mikeland73 wants to merge 4 commits into
mikeland73 wants to merge 4 commits into
Conversation
The --config flag lets users point devbox at a devbox.json in a non-default location. There was no way to set it via the environment, which is awkward in contexts like a Dockerfile where passing the flag to every command is repetitive. Default the --config flag to the DEVBOX_CONFIG environment variable when the flag isn't passed. An explicitly passed flag still takes precedence. Fixes #245
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for setting the --config flag via a new DEVBOX_CONFIG environment variable, so users can avoid passing --config repeatedly (e.g., in Dockerfiles). Explicit --config/-c still takes precedence.
Changes:
- Introduces
envir.DevboxConfig(DEVBOX_CONFIG) constant. - Uses
os.Getenv(envir.DevboxConfig)as the default for--configin bothregisterandregisterPersistent, with usage text mentioning the env var. - Adds
TestConfigFlagDefaultsToEnvcovering unset env, env-as-default, and explicit-flag-override cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/envir/env.go | Adds DevboxConfig constant with documentation. |
| internal/boxcli/config.go | Reads DEVBOX_CONFIG as default for --config; extracts shared usage string. |
| internal/boxcli/config_test.go | New unit tests verifying env-var default and flag override behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mohsenari
approved these changes
Jun 4, 2026
Collaborator
|
Idk why cli tests fail for this PR, worth a retry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #245.
The
--configflag lets users point devbox at adevbox.jsonthat lives in a non-default location. Until now there was no way to set it from the environment, which is awkward in contexts where passing the flag to every invocation is repetitive — the motivating example in the issue is a Dockerfile:This PR defaults the
--configflag to theDEVBOX_CONFIGenvironment variable when the flag isn't passed explicitly. An explicitly passed--config/-cflag still takes precedence over the env var.Changes
DevboxConfig(DEVBOX_CONFIG) constant ininternal/envir.os.Getenv(DEVBOX_CONFIG)as the default value for the--configflag in bothregisterandregisterPersistent, and mention the env var in the flag usage text.TestConfigFlagDefaultsToEnvcovering: unset env, env-as-default, and explicit-flag-overrides-env.Notes / scope
Issue #245 also mentions a
--cacheflag. devbox no longer exposes a--cacheflag for the.devboxdirectory location (DEVBOX_CACHEtoday is used for a different purpose — the nixpkgs cache base URL), so this PR scopes the change to the--configflag, which is the part that's actionable against the current CLI. Happy to follow up if a configurable.devboxpath is still desired (tracked separately in #244).Testing
https://claude.ai/code/session_01UQSFvFRfQ4Ku4F4LXbKjFn
Generated by Claude Code