Skip to content

docs(contributing): document how to debug Devbox locally#2893

Open
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-6nhmso
Open

docs(contributing): document how to debug Devbox locally#2893
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-6nhmso

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

Resolves #2699.

Several Devbox commands (e.g. devbox shell, devbox services up) do little work themselves — they re-exec a nested devbox subprocess inside the project's shell environment, and that subprocess does the real work. The nested process is resolved from PATH, so it's usually the installed version of Devbox rather than the local build you're editing. This is why devbox run build && dist/devbox services up may silently run old code, and why DEVBOX_DEBUG=1 logs / 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.md describing the two workarounds they found:

  1. Point the launcher at your local build via DEVBOX_USE_VERSION (most faithful — every invocation, including nested subprocesses, uses your build).
  2. The hidden --run-in-current-shell flag (quick to iterate, but bypasses the nested re-exec so behavior differs slightly).

Verification

The documented behavior was confirmed against the code:

  • devbox run builddist/devbox (devbox.json).
  • devbox services … re-execs a nested devbox subprocess unless --run-in-current-shell is set (internal/devbox/services.gorunDevboxServicesScript runs the devbox on PATH inside the shell; the flag is registered hidden in internal/boxcli/services.go).
  • DEVBOX_USE_VERSION is 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

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
Copilot AI review requested due to automatic review settings June 25, 2026 14:10

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

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 devbox subprocess 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.

Comment thread CONTRIBUTING.md
Comment thread CONTRIBUTING.md Outdated
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
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.

nested shells make it harder to debug issues; document workarounds for better local dev

3 participants