Skip to content

Fix indentation in default devbox config#2851

Open
humtta wants to merge 1 commit into
jetify-com:mainfrom
humtta-forks:fix/default-config-json-indentation
Open

Fix indentation in default devbox config#2851
humtta wants to merge 1 commit into
jetify-com:mainfrom
humtta-forks:fix/default-config-json-indentation

Conversation

@humtta

@humtta humtta commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

DefaultConfig() defines the default configuration using a raw string literal directly in the function body. Because raw string literals in Go preserve all whitespace, the resulting JSON ends up with extra leading spaces on almost every line.

This fix extracts the template into a package-level const, so the string starts at column zero and the resulting JSON is well-formed.

devbox.json before the change:

{␊
····"$schema":·"https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox.schema.json",␊
····"packages":·[],␊
····"shell":·{␊
······"init_hook":·[␊
········"echo·'Welcome·to·devbox!'·>·/dev/null"␊
······],␊
······"scripts":·{␊
········"test":·[␊
··········"echo·\"Error:·no·test·specified\"·&&·exit·1"␊
········]␊
······}␊
····}␊
··}␊
··

devbox.json after the change:

{␊
··"$schema":·"https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox.schema.json",␊
··"packages":·[],␊
··"shell":·{␊
····"init_hook":·[␊
······"echo·'Welcome·to·devbox!'·>·/dev/null"␊
····],␊
····"scripts":·{␊
······"test":·[␊
········"echo·\"Error:·no·test·specified\"·&&·exit·1"␊
······]␊
····}␊
··}␊
}␊

How was it tested?

Ran devbox init locally and inspected the generated devbox.json before and after the 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the formatting of the generated default devbox.json by moving the raw JSON template out of DefaultConfig() into a package-level constant, avoiding extra indentation introduced by Go source-level whitespace in raw string literals.

Changes:

  • Extracted the default devbox config JSON template into a package-level const defaultConfig.
  • Simplified DefaultConfig() by computing schemaVersion once and formatting the template via fmt.Sprintf.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants