Skip to content

Incorrect ZDOTDIR #2297

@BeyondEvil

Description

@BeyondEvil

What happened?

Devbox fails to read the ZDOTDIR environment variable falling back to the shellrc path, causing issues with my .zshrc file.

Steps to reproduce

  1. Create a .zshenv in the $HOME directory with the following contents:
export ZDOTDIR=~/.config/zsh
[[ -f $ZDOTDIR/.zshenv ]] && . $ZDOTDIR/.zshenv
  1. Inside ~/.config/zsh create a .zshrc file with the following content:
echo "ZDOTDIR in .zshrc file: ${ZDOTDIR}"
  1. Run devbox shell and note that the output from the .zshrc file is the shellrc path, and not the path specified in ZDOTDIR. But the echo from the init_hook is correct. (See the debug logs.)

Command

shell

devbox.json

{
  "$schema":  "https://raw.githubusercontent.com/jetify-com/devbox/0.13.0/.schema/devbox.schema.json",
  "packages": ["dotnet-sdk_8@latest"],
  "shell": {
    "init_hook": [
      "echo ZDOTDIR from init_hook: $ZDOTDIR"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

Devbox version

0.13.0

Nix version

nix (Nix) 2.18.1

What system does this bug occur on?

macOS (Apple Silicon) (Sonoma 14.6.1)

Debug logs

❯ DEVBOX_DEBUG=1 devbox shell

time=2024-09-24T22:55:14.861+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-09-24T22:55:14.861+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-09-24T22:55:14.861+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/Users/jimbrannlund/dev/cosafe/Cosafe-backend/devbox.json dur=993.542µs
time=2024-09-24T22:55:14.861+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:202 msg="package doesn't need patching" pkg=dotnet-sdk_8 mode=auto
time=2024-09-24T22:55:14.862+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-09-24T22:55:14.862+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-09-24T22:55:14.862+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/Users/jimbrannlund/dev/cosafe/Cosafe-backend/devbox.json dur=64.5µs
time=2024-09-24T22:55:14.862+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:202 msg="package doesn't need patching" pkg=dotnet-sdk_8 mode=auto
time=2024-09-24T22:55:14.927+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/nix.go:337 msg="nix --version --debug output" out="nix (Nix) 2.18.1\nSystem type: aarch64-darwin\nAdditional system types: x86_64-darwin\nFeatures: gc, signed-caches\nSystem configuration file: /etc/nix/nix.conf\nUser configuration files: /Users/jimbrannlund/.config/nix/nix.conf:/etc/xdg/nix/nix.conf\nStore directory: /nix/store\nState directory: /nix/var/nix\nData directory: /nix/store/0pbq6wzr2f1jgpn5212knyxpwmkjgjah-nix-2.18.1/share\n"
time=2024-09-24T22:55:14.927+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' eval --impure --raw --expr builtins.currentSystem" cmd.path=/nix/var/nix/profiles/default/bin/nix
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' eval --impure --raw --expr builtins.currentSystem" cmd.path=/nix/var/nix/profiles/default/bin/nix cmd.pid=54981 cmd.code=0 cmd.dur=45.609958ms
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/Users/jimbrannlund/dev/cosafe/Cosafe-backend/devbox.json dur=135.792µs
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:202 msg="package doesn't need patching" pkg=dotnet-sdk_8 mode=auto
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:202 msg="package doesn't need patching" pkg=dotnet-sdk_8 mode=auto
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:202 msg="package doesn't need patching" pkg=dotnet-sdk_8 mode=auto
time=2024-09-24T22:55:14.973+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:685 msg="current environment PATH" path=/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jimbrannlund/bin:/Users/jimbrannlund/.local/bin:/Users/jimbrannlund/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
time=2024-09-24T22:55:14.974+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:700 msg="nix environment PATH" path=/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0/bin:/nix/store/ljz45vk739778lw2xaw2jvy7ihip2q07-clang-11.1.0/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/m488d5iwzn93bdk1j5gxl77k3zb8y285-cctools-binutils-darwin-wrapper-11.1.0-973.0.1/bin:/nix/store/x5bm27csww06snmzrsqhxfzl0i8mad5c-cctools-binutils-darwin-11.1.0-973.0.1/bin:/nix/store/ihiwqrcpyk1yma9ak98vmqr4jjjfpk54-dotnet-sdk-8.0.401/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0/bin:/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10/bin:/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9/bin:/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11/bin:/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2/bin:/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35/bin:/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13/bin:/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin/bin:/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1/bin:/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin:/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6/bin:/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin/bin:/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45/bin
time=2024-09-24T22:55:14.974+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:734 msg="PATH after plugins and config" path=/Users/jimbrannlund/dev/cosafe/Cosafe-backend/.devbox/nix/profile/default/bin:/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0/bin:/nix/store/ljz45vk739778lw2xaw2jvy7ihip2q07-clang-11.1.0/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/m488d5iwzn93bdk1j5gxl77k3zb8y285-cctools-binutils-darwin-wrapper-11.1.0-973.0.1/bin:/nix/store/x5bm27csww06snmzrsqhxfzl0i8mad5c-cctools-binutils-darwin-11.1.0-973.0.1/bin:/nix/store/ihiwqrcpyk1yma9ak98vmqr4jjjfpk54-dotnet-sdk-8.0.401/bin:/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0/bin:/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10/bin:/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9/bin:/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11/bin:/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2/bin:/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35/bin:/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13/bin:/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin/bin:/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1/bin:/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin:/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6/bin:/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin/bin:/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45/bin
time=2024-09-24T22:55:14.974+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:752 msg="filtering out buildInput from PATH" path=/nix/store/ihiwqrcpyk1yma9ak98vmqr4jjjfpk54-dotnet-sdk-8.0.401/bin input=/nix/store/ihiwqrcpyk1yma9ak98vmqr4jjjfpk54-dotnet-sdk-8.0.401
time=2024-09-24T22:55:14.974+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:758 msg="PATH after filtering buildInputs" inputs=[/nix/store/ihiwqrcpyk1yma9ak98vmqr4jjjfpk54-dotnet-sdk-8.0.401] path=/Users/jimbrannlund/dev/cosafe/Cosafe-backend/.devbox/nix/profile/default/bin:/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0/bin:/nix/store/ljz45vk739778lw2xaw2jvy7ihip2q07-clang-11.1.0/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/m488d5iwzn93bdk1j5gxl77k3zb8y285-cctools-binutils-darwin-wrapper-11.1.0-973.0.1/bin:/nix/store/x5bm27csww06snmzrsqhxfzl0i8mad5c-cctools-binutils-darwin-11.1.0-973.0.1/bin:/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0/bin:/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10/bin:/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9/bin:/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11/bin:/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2/bin:/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35/bin:/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13/bin:/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin/bin:/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1/bin:/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin:/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6/bin:/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin/bin:/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45/bin
time=2024-09-24T22:55:14.975+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:202 msg="package doesn't need patching" pkg=dotnet-sdk_8 mode=auto
time=2024-09-24T22:55:14.975+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:777 msg="new path stack is" path_stack=DEVBOX_NIX_ENV_PATH_b4ebeeaba9e0035707b2e22b228bc9d545c9dfd5a11287dc99f9d39d1f5db82d:DEVBOX_INIT_PATH
time=2024-09-24T22:55:14.975+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/devbox.go:779 msg="computed environment PATH" path=/Users/jimbrannlund/dev/cosafe/Cosafe-backend/.devbox/nix/profile/default/bin:/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0/bin:/nix/store/ljz45vk739778lw2xaw2jvy7ihip2q07-clang-11.1.0/bin:/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3/bin:/nix/store/m488d5iwzn93bdk1j5gxl77k3zb8y285-cctools-binutils-darwin-wrapper-11.1.0-973.0.1/bin:/nix/store/x5bm27csww06snmzrsqhxfzl0i8mad5c-cctools-binutils-darwin-11.1.0-973.0.1/bin:/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0/bin:/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10/bin:/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9/bin:/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11/bin:/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2/bin:/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35/bin:/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13/bin:/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin/bin:/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1/bin:/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin:/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6/bin:/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin/bin:/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45/bin:/Users/jimbrannlund/dev/cosafe/Cosafe-backend/.devbox/virtenv/runx/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jimbrannlund/bin:/Users/jimbrannlund/.local/bin:/Users/jimbrannlund/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
Starting a devbox shell...
time=2024-09-24T22:55:14.975+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/shell.go:102 msg="using SHELL env var for shell binary path" shell=/bin/zsh
time=2024-09-24T22:55:14.975+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/shell.go:86 msg="detected user shell" shell=/bin/zsh initrc=/Users/jimbrannlund/.config/zsh/.zshrc
time=2024-09-24T22:55:14.976+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/shell.go:346 msg="wrote devbox shellrc" path=/var/folders/jc/xz2fbyhn087d19yt4bcdhfvw0000gn/T/devbox2047249374/.zshrc
time=2024-09-24T22:55:14.980+02:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/shell.go:247 msg="Executing shell %s with args: %v" /bin/zsh=[/bin/zsh]
ZDOTDIR in .zshrc file: /var/folders/jc/xz2fbyhn087d19yt4bcdhfvw0000gn/T/devbox2047249374
ZDOTDIR from init_hook: /Users/jimbrannlund/.config/zsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue needs triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions