feat(config): discover devbox.json in a .config subdirectory - #2947
Open
mikeland73 wants to merge 1 commit into
Open
feat(config): discover devbox.json in a .config subdirectory#2947mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
Devbox now looks for a config file in `.config/devbox.json` in addition to `devbox.json` at the top of a directory. This lets projects keep their root directory tidy by moving devbox.json (and the `.devbox` state that lives alongside it) under `.config`. A top-level `devbox.json` still takes precedence, so existing projects are unaffected. Both `Open` (single directory) and `Find` (walking up parent directories) honor the new location. Fixes #2792 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VgaUq2F9Drmri6oRUp5duV
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 #2792.
Devbox now discovers a config file at
.config/devbox.jsonin addition to a top-leveldevbox.json. This lets projects keep their root directory tidy by moving the Devbox config (and the.devboxstate that lives alongside it) under a.configdirectory, instead of adding yet another dotfile/config file to the project root.Behavior:
devbox.jsondirectly in it, then falls back to<dir>/.config/devbox.json.devbox.jsonalways takes precedence, so existing projects are completely unaffected — the new location is only used when no root-level config exists.Open(single directory) andFind(walking up parent directories) honor the new location, so runningdevboxfrom a subdirectory of a project that stores its config under.configworks as expected.The change is small and localized to
searchDir, which already used a[]stringof candidate names — the project-directory anchoring semantics (project dir = the directory containing the resolved config file) are unchanged, so.config/devbox.jsonkeeps its state self-contained under.config.Note: this implements the
devbox.jsonhalf of the request.process-compose.ymldiscovery was left out of scope for this change to keep it focused and low-risk.cc @eknowles (issue reporter)
How was it tested?
Added unit tests in
internal/devconfig/config_test.go(TestConfigSubdir) covering:Openfinding.config/devbox.json.devbox.jsontaking precedence over.config/devbox.json.Findlocating.config/devbox.jsonin a parent directory when invoked from a child directory.go build ./...,go vet ./internal/devconfig/..., andgofmtare clean. The new tests pass. (Two unrelated pre-existing failures inTestFindError/PermissionsandTestFindError/ExactFilePermissionsoccur only because the test environment runs as root, which bypasseschmod 0o000; they fail identically on the base commit and are untouched by this change.)Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
Generated by Claude Code