jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
8.84k stars 208 forks source link

Devbox installs two Python packages to /nix/store #2410

Open apgrucza opened 1 week ago

apgrucza commented 1 week ago

What happened?

Since Devbox 0.13.0, adding the python package to devbox.json causes two Python packages to be added to /nix/store (same version but different hashes). To reduce storage and improve speed, only one package should be installed.

The problem does not occur if you specify python3 instead of python.

Steps to reproduce

I've put the steps in a Dockerfile to make it easy to test this with a clean slate.

Dockerfile

FROM jetpackio/devbox:0.13.6
WORKDIR /home/devbox
RUN devbox init
ARG PKG
RUN devbox add ${PKG}
RUN devbox install

Using python:

docker build -t devbox-python --build-arg PKG=python@3.12.6 .
docker run --rm devbox-python ls /nix/store | grep python3-3.12.6$
docker image ls devbox-python

Output shows two Python packages in /nix/store and large image size:

17wcwdw4mzk31x5qbmalkqa43155zj79-python3-3.12.6
wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6
REPOSITORY      TAG       IMAGE ID       CREATED          SIZE
devbox-python   latest    65d021ce8cdd   26 seconds ago   2.69GB

Using python3:

docker build -t devbox-python3 --build-arg PKG=python3@3.12.6 .
docker run --rm devbox-python3 ls /nix/store | grep python3-3.12.6$
docker image ls devbox-python3

Output shows one Python package in /nix/store and smaller image size:

wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6
REPOSITORY       TAG       IMAGE ID       CREATED         SIZE
devbox-python3   latest    155b0e3cee81   8 seconds ago   1.27GB

Command

install

devbox.json

{
  "packages": ["python@3.12.6"],
}

Devbox version

0.13.6

Nix version

nix (Nix) 2.24.7

What system does this bug occur on?

Linux (x86-64)

Debug logs

time=2024-11-15T04:16:28.622Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-11-15T04:16:28.623Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-11-15T04:16:28.623Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/devbox/devbox.json dur=1.427841ms
time=2024-11-15T04:16:28.623Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.623Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-11-15T04:16:28.623Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-11-15T04:16:28.623Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/devbox/devbox.json dur=256.574µs
time=2024-11-15T04:16:28.624Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.642Z level=DEBUG source=go.jetpack.io/devbox/internal/nix/nix.go:342 msg="nix --version --debug output" out="nix (Nix) 2.24.9\nSystem type: x86_64-linux\nAdditional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux\nFeatures: gc, signed-caches\nSystem configuration file: /etc/nix/nix.conf\nUser configuration files: /home/devbox/.config/nix/nix.conf:/etc/xdg/nix/nix.conf\nStore directory: /nix/store\nState directory: /nix/var/nix\nData directory: /nix/store/2nhrwv91g6ycpyxvhmvc0xs8p92wp4bk-nix-2.24.9/share\n"
time=2024-11-15T04:16:28.642Z 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=/home/devbox/.nix-profile/bin/nix
time=2024-11-15T04:16:28.672Z 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=/home/devbox/.nix-profile/bin/nix cmd.pid=57 cmd.code=0 cmd.dur=29.649295ms
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/devbox/devbox.json dur=114.349µs
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
Info: Ensuring packages are installed.
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:85 msg="creating files for package" pkg=python@3.12.6
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:128 msg="Creating file %q from contentPath: %q" /home/devbox/.devbox/virtenv/python/bin/venvShellHook.sh=python/venvShellHook.sh
time=2024-11-15T04:16:28.672Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.672Z 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' path-info --offline --json /nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6" cmd.path=/home/devbox/.nix-profile/bin/nix
time=2024-11-15T04:16:28.691Z 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' path-info --offline --json /nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6" cmd.path=/home/devbox/.nix-profile/bin/nix cmd.pid=60 cmd.code=0 cmd.dur=18.945591ms
time=2024-11-15T04:16:28.692Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.692Z level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:85 msg="creating files for package" pkg=python3
time=2024-11-15T04:16:28.692Z level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:128 msg="Creating file %q from contentPath: %q" /home/devbox/.devbox/virtenv/python/bin/venvShellHook.sh=python/venvShellHook.sh
time=2024-11-15T04:16:28.692Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:16:28.692Z level=DEBUG source=go.jetpack.io/devbox/internal/shellgen/flake_plan.go:155 msg="creating new patch flake" flake.inputs.devbox=github:jetify-com/devbox/0.13.6 flake.inputs.nixpkgs-glibc=flake:nixpkgs/75a52265bda7fd25e06e3a67dee3f0354e73243c flake.inputs.nixpkgs-d4f247=github:NixOS/nixpkgs/d4f247e89f6e10120f911e2e2d2254a050d0f732 flake.outputs=[python3]
time=2024-11-15T04:16:28.692Z level=DEBUG source=go.jetpack.io/devbox/internal/nix/nix.go:85 msg="running print-dev-env cmd" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/devbox/.devbox/gen/flake"
time=2024-11-15T04:16:28.692Z 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' print-dev-env --json path:/home/devbox/.devbox/gen/flake" cmd.path=/home/devbox/.nix-profile/bin/nix
time=2024-11-15T04:18:01.659Z 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' print-dev-env --json path:/home/devbox/.devbox/gen/flake" cmd.path=/home/devbox/.nix-profile/bin/nix cmd.pid=63 cmd.code=0 cmd.dur=1m33.229195397s
time=2024-11-15T04:18:01.660Z 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' profile list --profile /home/devbox/.devbox/nix/profile/default --json" cmd.path=/home/devbox/.nix-profile/bin/nix
time=2024-11-15T04:18:01.681Z 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' profile list --profile /home/devbox/.devbox/nix/profile/default --json" cmd.path=/home/devbox/.nix-profile/bin/nix cmd.pid=19042 cmd.code=0 cmd.dur=20.765646ms
time=2024-11-15T04:18:01.681Z level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:47 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' profile install --profile /home/devbox/.devbox/nix/profile/default --offline --impure --priority 6 /nix/store/17wcwdw4mzk31x5qbmalkqa43155zj79-python3-3.12.6" cmd.path=/home/devbox/.nix-profile/bin/nix
time=2024-11-15T04:18:01.712Z level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:54 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' profile install --profile /home/devbox/.devbox/nix/profile/default --offline --impure --priority 6 /nix/store/17wcwdw4mzk31x5qbmalkqa43155zj79-python3-3.12.6" cmd.path=/home/devbox/.nix-profile/bin/nix cmd.pid=19045 cmd.code=0 cmd.dur=30.943965ms
time=2024-11-15T04:18:01.712Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2024-11-15T04:18:01.712Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
Finished installing packages.
time=2024-11-15T04:18:01.712Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2024-11-15T04:18:01.712Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2024-11-15T04:18:01.713Z level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/devbox/devbox.json dur=118.747µs
time=2024-11-15T04:18:01.713Z level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto