fix(services): re-invoke devbox by executable path, not hardcoded name (#1321) - #2936
Open
mikeland73 wants to merge 1 commit into
Open
fix(services): re-invoke devbox by executable path, not hardcoded name (#1321)#2936mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
#1321) `devbox services start|stop|ls|restart|up` re-invoke devbox inside the computed environment via a generated run script that eval's a command beginning with the literal string "devbox". This required the binary to be named exactly "devbox" and resolvable on PATH; any other name (e.g. a renamed or versioned install) broke services commands with "devbox: command not found". Use os.Executable() to reference the currently running binary (shell- quoted so paths with spaces survive the eval), falling back to "devbox" only if the executable path can't be determined. Fixes #1321.
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 #1321.
devbox services start|stop|ls|restart(and the non-current-shell path ofdevbox services up) work by re-invoking devbox inside the computed environment.runDevboxServicesScriptbuilds a command and hands it toRunScript, which writes a small script thatevals the command. The command began with the hard-coded string"devbox":So the generated script effectively runs
eval "devbox services ...", which requires the binary to be named exactlydevboxand be resolvable onPATH. If the binary is installed or renamed to anything else (a versioned install, a wrapper,devbox-cli, etc.), services commands fail withdevbox: command not found.This was the only real self-invocation of the binary — the process-compose manager already shells out via
processComposeConfig.BinPath, and every otherdevbox ...occurrence in the services code is user-facing help text.Fix
Reference the currently running binary via
os.Executable()instead of the literal"devbox". The path is shell-quoted (viastrconv.Quote, matching how the surrounding code already quotes arguments before they areeval'd) so it survives the eval even if it contains spaces. If the executable path can't be determined, it falls back to"devbox"— the previous PATH-lookup behavior.This mirrors the existing use of
os.Executable()ininternal/devbox/pure_shell.go.How was it tested?
go build ./...— clean.go vet ./internal/devbox/— clean.gofmt— no diffs.TestDevboxBinaryForSelfInvocationininternal/devbox/services_test.go, which asserts the helper returns the shell-quoted path to the running binary rather than the literal"devbox". It passes:cc @mikeland73 (issue reporter)
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 with Claude Code
https://claude.ai/code/session_01BQ4KvbTQb7oJ2M3tc79DuG
Generated by Claude Code