Skip to content

Pre-load Devbox environment in container entrypoints for LLM agents and CI/CD #2797

Description

@auyer

What problem are you trying to solve?

I want to run automated scripts or agents inside a Devbox-managed container where dependencies installed via devbox.json are immediately available in PATH—without requiring an interactive devbox shell session.
Currently, when launching a container (e.g., via devbox run or Docker), the environment variables and PATH modifications from Devbox are not applied unless the process runs inside an interactive Devbox shell. This breaks headless/automated workflows like CI jobs, LLM agents, or background services that need project-specific tools (e.g., go, python, node, custom binaries) available at startup.
Specifically, I'm building agentbox, where an LLM agent runs inside a container and needs immediate access to the project's toolchain to execute, test, or debug code. Having to manually enter devbox shell first defeats the purpose of an autonomous, reproducible environment.

What solution would you like?

Add support for non-interactive environment activation in Devbox containers. Specifically:

  1. devbox shell -c "<command>" (similar to bash -c) or similar flag that executes a command with the full Devbox environment (PATH, env vars, etc.). This is differs from commands from "devbox run" because thery are not defined in the devbox.json file.
  2. Container entrypoint option: Allow specifying a command in devbox.json or via CLI that runs automatically with the environment pre-loaded when the container starts (e.g., devbox container run --entrypoint "my-agent").
  3. Exportable environment script: Generate a shell script (e.g., devbox export-env) that can be sourced in a Dockerfile or entrypoint to initialize the environment for any subsequent command.

This would enable headless automation while preserving Devbox's reproducible dependency management—no need to bake custom images or manually manage PATH.

Alternatives you've considered

  • Manual eval "$(devbox shellenv)" in entrypoint: This works in some cases but adds complexity, requires bash/shell, and isn't officially documented for container use. It also doesn't handle all edge cases (e.g., non-shell processes).
  • Custom Docker images per project: Defeats the purpose of Devbox's dynamic environment management and increases build/maintenance overhead.
  • Wrapper scripts that invoke a command inside something like devox run -- bash or devbox shell -c "command": Limited by the fact that devbox shell is designed for interactive use; non-interactive usage is unreliable or unsupported.

Activity

  1. mikeland73 commented on Sep 28, 2026

    @mikeland73
    Collaborator

    Triage: p3, no difficulty label. Most of this already exists on current main, so what remains is mainly a documentation gap.

    1. Run any command in the environment without an interactive shell. devbox run accepts commands that aren't in devbox.json. From devbox run --help: "The script must be defined in devbox.json, or else it will be interpreted as an arbitrary command", e.g. devbox run -- my-agent --flag. Init hooks run as well. This is the devbox shell -c you're asking for.
    2. Exportable env script. devbox shellenv (supports --init-hook, --install, --pure) prints exports you can eval "$(devbox shellenv --init-hook)" in an entrypoint or Dockerfile RUN.
    3. Container entrypoint. devbox generate dockerfile templates (internal/devbox/generate/tmpl/) default to CMD ["devbox", "shell"] for dev and CMD [{{ .Cmd }}] for prod. You can set ENTRYPOINT ["devbox", "run", "--"] so every command runs inside the environment.

    I couldn't run an end-to-end container test here because my sandbox couldn't fetch nixpkgs. If one of these fails for a specific case, please share the command and the error. Otherwise the remaining work is a docs/guide for headless, CI and agent usage.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions