docs(contributing): document how to debug Devbox locally#2893
Open
mikeland73 wants to merge 2 commits into
Open
docs(contributing): document how to debug Devbox locally#2893mikeland73 wants to merge 2 commits into
mikeland73 wants to merge 2 commits into
Conversation
Many commands (e.g. `devbox shell`, `devbox services up`) re-exec a nested `devbox` subprocess that does the real work. That subprocess is resolved from PATH, so it is typically the installed Devbox rather than your local build, which is why debug logs/breakpoints added to a local build don't fire. Add a "Debugging Devbox Locally" section to CONTRIBUTING.md describing the two workarounds: pointing the launcher at a local build via DEVBOX_USE_VERSION (most faithful), and the hidden `--run-in-current-shell` flag (quick). Fixes #2699 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014fiBLNEAEGUcCJPZ1qpGp6
Contributor
There was a problem hiding this comment.
Pull request overview
Adds contributor documentation explaining why some Devbox commands don’t execute the locally-built binary (due to nested devbox re-exec from PATH) and how to reliably debug local changes.
Changes:
- Document the nested
devboxsubprocess behavior that can cause local builds/logs/breakpoints to be ignored. - Add two debugging workarounds:
DEVBOX_USE_VERSION(launcher override) and--run-in-current-shell(skip re-exec).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The launcher's binary cache lives under XDG_CACHE_HOME (falling back to
~/.cache), so use ${XDG_CACHE_HOME:-$HOME/.cache} instead of hard-coding
$HOME/.cache. Factor the path into a variable to avoid repetition.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fiBLNEAEGUcCJPZ1qpGp6
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
Resolves #2699.
Several Devbox commands (e.g.
devbox shell,devbox services up) do little work themselves — they re-exec a nesteddevboxsubprocess inside the project's shell environment, and that subprocess does the real work. The nested process is resolved fromPATH, so it's usually the installed version of Devbox rather than the local build you're editing. This is whydevbox run build && dist/devbox services upmay silently run old code, and whyDEVBOX_DEBUG=1logs / breakpoints added to a local build don't fire.The issue author hit exactly this and asked for it to be documented in the repo. This PR adds a "Debugging Devbox Locally" section to
CONTRIBUTING.mddescribing the two workarounds they found:DEVBOX_USE_VERSION(most faithful — every invocation, including nested subprocesses, uses your build).--run-in-current-shellflag (quick to iterate, but bypasses the nested re-exec so behavior differs slightly).Verification
The documented behavior was confirmed against the code:
devbox run build→dist/devbox(devbox.json).devbox services …re-execs a nesteddevboxsubprocess unless--run-in-current-shellis set (internal/devbox/services.go—runDevboxServicesScriptruns thedevboxon PATH inside the shell; the flag is registered hidden ininternal/boxcli/services.go).DEVBOX_USE_VERSIONis the version-override env the launcher honors and that Devbox preserves across re-launches (internal/setup/setup.go,internal/devbox/providers/nixcache/setup.go).Docs-only change; no code paths affected.
cc @jay-aye-see-kay (issue author) — thanks for the detailed write-up of the workaround.
🤖 Generated with Claude Code
https://claude.ai/code/session_014fiBLNEAEGUcCJPZ1qpGp6
Generated by Claude Code