Skip to content

docs(run): document that scripts and commands run from the project root - #2948

Open
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-xxqpkb
Open

docs(run): document that scripts and commands run from the project root#2948
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-xxqpkb

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

devbox run always executes from the project's root directory — the directory
containing devbox.json — regardless of the subdirectory it was invoked from.
This is enforced in nix.RunScript, which sets cmd.Dir = projectDir
(internal/nix/run.go). Users invoking devbox run from a subdirectory are
surprised that pwd and relative paths resolve against the project root rather
than the current working directory, as reported in #2559.

A maintainer confirmed on the issue that this is intentional: it keeps a command
run via devbox run -- <cmd> consistent with a script defined in devbox.json,
which should always run from the same place. The reporter's remaining ask was
simply that this behavior be surfaced in the command's help.

This PR adds a short paragraph to the devbox run long help explaining that
scripts and commands run from the project root and showing how to run from a
subdirectory when needed:

Scripts and commands always run from the project's root directory (the directory
containing your devbox.json), not the current working directory. If you invoke
devbox run from a subdirectory and need to run there, change into it as part of
your command, e.g. devbox run -- sh -c 'cd subdir && <command>'.

No behavior changes — documentation only.

Closes #2559

cc @alezkv (issue reporter) — thanks for raising this.

How was it tested?

  • go build ./internal/boxcli/ and gofmt -l internal/boxcli/run.go are clean.
  • Ran devbox run --help and confirmed the new paragraph renders correctly in
    the long description, above the usage/examples output.

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 by Claude Code

`devbox run` always executes from the directory containing devbox.json
(cmd.Dir is set to the project dir in nix.RunScript), regardless of the
subdirectory the command is invoked from. This surprises users who expect
the current working directory to be respected, as reported in #2559.

A maintainer confirmed the behavior is intentional so that a command run
via `devbox run -- <cmd>` behaves consistently with a script defined in
devbox.json. The reporter's follow-up ask was simply to surface this in
the command help. Add a short paragraph to the `devbox run` long help
explaining the working-directory behavior and how to run from a
subdirectory.

Closes #2559
Copilot AI lite review requested due to automatic review settings August 13, 2026 14:16

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Question: Why is PWD ignored when using devbox run?

3 participants