Flox containerize stops working after flox edit

Flox edit creates new generation but it is not created in /nix/store/*-source folder. This confuses a flox containerize that cannot find new generation folder.

Are you getting ERROR: No matching environments found? That may be fixed in r633 - what’s your flox --version?

λ flox containerize -e test > ~/docker
Building container...
Done.
No 'fromImage' provided
Creating layer 1 from paths: ['/nix/store/s2gi8pfjszy6rq3ydx0z1vwbbskw994i-libunistring-1.1']
Creating layer 2 from paths: ['/nix/store/k8ivghpggjrq1n49xp8sj116i4sh8lia-libidn2-2.3.4']
Creating layer 3 from paths: ['/nix/store/jbwb8d8l28lg9z0xzl784wyb9vlbwss6-xgcc-12.3.0-libgcc']
Creating layer 4 from paths: ['/nix/sto
...

λ flox edit -e test # add a new line in shell.hook
warning: remote HEAD refers to nonexistent ref, unable to checkout
warning: input 'flox-floxpkgs/etc-profiles' has an override for a non-existent input 'flox-floxpkgs'
Environment 'test' modified.

λ flox containerize -e test > ~/docker
Building container...
error: getting status of '/nix/store/7fl0p4j4x2zbjg203z9cnbq92c2kij63-source/8': No such file or directory
ERROR: Nix failed with: [exit status: 1]

λ flox --version
Version: 0.3.4-r638

Hmm I’m struggling to reproduce:

> flox --version
Version: 0.3.4-r638
> flox destroy -e test
Nothing to delete for the 'aarch64-darwin.test' environment
> flox install -e test hello
...
Installed 'hello' package(s) into 'test' environment.
> flox containerize -e test > ~/docker
Building container...
Done.
No 'fromImage' provided
Creating layer 1 from paths: ['/nix/store/hjlf7fscq2mihg4b1y28cpgmp0j9pxg5-hello-2.12.1']
...
Creating layer 17 from paths: ['/nix/store/p5kwl9j2y6adxzwl4vcj29b46a4sy84s-coreutils-9.3']
Creating layer 18 with customisation...
Adding manifests...
Done.
> flox edit -e test
warning: input 'flox-floxpkgs/etc-profiles' has an override for a non-existent input 'flox-floxpkgs'
Environment 'test' modified.
> flox containerize -e test > ~/docker
Building container...
Done.
No 'fromImage' provided
Creating layer 1 from paths: ['/nix/store/hjlf7fscq2mihg4b1y28cpgmp0j9pxg5-hello-2.12.1']
...
Creating layer 17 from paths: ['/nix/store/p5kwl9j2y6adxzwl4vcj29b46a4sy84s-coreutils-9.3']
Creating layer 18 with customisation...
Adding manifests...
Done.

I wonder if there’s some other state that your environment is - are you at generation 8?

Immediate containerize run will fail, I tested now on new environment:

flox create -e cont-test
flox install -e cont-test hello
flox containerize -e cont-test | docker load
flox edit -e cont-test # remove the comment from # echo Flox Environment | figlet line
flox containerize -e cont-test | docker load # Fail

Building container...
error: getting status of '/nix/store/yfj1csj4i1az21mzpm1w4np307ypbnw1-source/3': No such file or directory
ERROR: Nix failed with: [exit status: 1]
open /var/lib/docker/tmp/docker-import-921281233/repositories: no such file or directory

For the cont-test, latest is generation 3 :

λ flox history -e cont-test
Tue Oct 10 18:24:53 2023 +0200 dgoslawski edited declarative profile (generation 3)

flox edit

Tue Oct 10 18:24:19 2023 +0200 dgoslawski installed stable.nixpkgs-flox.hello

flox install hello
  stable.nixpkgs-flox.hello: ∅ -> 2.12.1

Tue Oct 10 18:24:05 2023 +0200 dgoslawski created environment

flox create

Tue Oct 10 18:24:04 2023 +0200 dgoslawski created environment x86_64-linux.cont-test (x86_64-linux)

It seems to self-heal after a while, right now I can do a containerize for test env, but if I do edit it, it will fail again.

Can you send the output of a failing flox --debug containerize -e cont-test | docker load (I added the --debug)?

I checked this on new, fresh machine and the same effect:

[DEBUG] [flox::config] `$FLOX_CONFIG_HOME` not set, using "/home/dawid/.config/flox/"
[DEBUG] [flox::utils::init] no default user nix.conf found - weird
[DEBUG] [flox::utils::init::metrics] Attempting to read own UUID from file
[DEBUG] [posix] + "/nix/store/whnrbi502jasi4bj6kai31q3fiky6w62-git-minimal-2.41.0/bin/git" "-C" "/home/dawid/.cache/flox/meta/local" "-c" "user.name=Flox User" "-c" "user.email=floxuser@example.invalid" "rev-parse" "--is-bare-repository"
[DEBUG] [posix] + "/nix/store/whnrbi502jasi4bj6kai31q3fiky6w62-git-minimal-2.41.0/bin/git" "-C" "/home/dawid/.cache/flox/meta/local" "-c" "user.name=Flox User" "-c" "user.email=floxuser@example.invalid" "show" "floxmain:floxUserMeta.json"
[DEBUG] [flox_rust_sdk::models::legacy_environment_ref] Finding environment for cont-test
[DEBUG] [posix] + "/nix/store/whnrbi502jasi4bj6kai31q3fiky6w62-git-minimal-2.41.0/bin/git" "-C" "/mnt/c/Users/dawid.DESKTOP-JCICJKE" "-c" "user.name=Flox User" "-c" "user.email=floxuser@example.invalid" "rev-parse" "--is-bare-repository"
[DEBUG] [flox::utils::metrics] Writing new metrics buffer entry
[DEBUG] [flox_rust_sdk::models::legacy_environment_ref] Not in a Git repository
[DEBUG] [flox_rust_sdk::models::legacy_environment_ref] Checking `local` symlink (`/home/dawid/.local/share/flox/environments/local`) for true name of default user
[DEBUG] [posix] + "/nix/store/whnrbi502jasi4bj6kai31q3fiky6w62-git-minimal-2.41.0/bin/git" "-C" "/home/dawid/.cache/flox/meta/local" "-c" "user.name=Flox User" "-c" "user.email=floxuser@example.invalid" "rev-parse" "--is-bare-repository"
[DEBUG] [posix] + "/nix/store/whnrbi502jasi4bj6kai31q3fiky6w62-git-minimal-2.41.0/bin/git" "-C" "/home/dawid/.cache/flox/meta/local" "-c" "user.name=Flox User" "-c" "user.email=floxuser@example.invalid" "rev-parse" "--is-bare-repository"
[DEBUG] [posix] + "/nix/store/whnrbi502jasi4bj6kai31q3fiky6w62-git-minimal-2.41.0/bin/git" "-C" "/home/dawid/.cache/flox/meta/local" "-c" "user.name=Flox User" "-c" "user.email=floxuser@example.invalid" "show" "x86_64-linux.cont-test:metadata.json"
[INFO] [flox::commands::package] Building container...
[DEBUG] [runix::command_line] Invoking /nix/store/vdzd2vqaapf5j09fs7p1j8qv053nzn8r-flox-bash-0.3.4-r638/libexec/flox/nix:
    env = {"FLOX_VERSION": Some("0.3.4-r638"), "NIX_USER_CONF_FILES": Some("/home/dawid/.config/flox/nix.conf")}
    args = [
        "--connect-timeout",
        "0",
        "--no-warn-dirty",
        "--connect-timeout",
        "0",
        "--no-warn-dirty",
        "build",
        "--json",
        "--impure",
        "git+file:///home/dawid/.cache/flox/meta/local?dir=3&ref=x86_64-linux.cont-test#.floxEnvs.x86_64-linux.default.passthru.streamLayeredImage",
        "--quiet",
        "--quiet",
    ]
[DEBUG] [posix] + FLOX_VERSION="0.3.4-r638" NIX_USER_CONF_FILES="/home/dawid/.config/flox/nix.conf" /nix/store/vdzd2vqaapf5j09fs7p1j8qv053nzn8r-flox-bash-0.3.4-r638/libexec/flox/nix --connect-timeout 0 --no-warn-dirty --connect-timeout 0 --no-warn-dirty build --json --impure 'git+file:///home/dawid/.cache/flox/meta/local?dir=3&ref=x86_64-linux.cont-test#.floxEnvs.x86_64-linux.default.passthru.streamLayeredImage' --quiet --quiet
error: getting status of '/nix/store/ygfjf9wg1k056dbkna9av847zppqa8ph-source/3': No such file or directory
[ERROR] [flox] Nix failed with: [exit status: 1]
open /var/lib/docker/tmp/docker-import-3726534124/repositories: no such file or directory

If you pass --refresh does it work? flox containerize --refresh -e cont-test

Yeah, it works with --refresh. Will all Nix options be passed if not recognized by flox?

It depends on the flox subcommand, but containerize currently does

Opening a bug to fix having to pass --refresh

2 Likes