docs(contributing): document how to debug Devbox locally - #2893
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
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
|
@claude please review this PR for correctness, and flag anything that would block merging. |
|
Claude finished @mikeland73's task in 3m 21s —— View job Review of PR #2893
What checks out:
Correctness concerns (worth fixing before merge):
Nothing here is a functional/build risk since this is docs-only, but #1 and #2 are factual inaccuracies in a doc whose whole purpose is precise debugging instructions, so I'd flag them as blocking for a docs PR. |
|
Closing: the root cause was fixed in #2936 — |
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