Skip to content

error: path is not valid using nix ==2.18.0 #9052

Open
@avdv

Description

@avdv

Describe the bug

On CI, we were seeing this problem:

Return code: 1
Error output:
these 2 derivations will be built:
  /nix/store/313azxr6w777rrgz0lcgkp5f0dlm2nvr-posix-toolchain.drv
  /nix/store/qp53d6mv3gs81akp4gv89pk9k7rb76zc-bazel-nixpkgs-posix-toolchain.drv
this path will be fetched (0.09 MiB download, 0.09 MiB unpacked):
  /nix/store/cqam21jchkwyp7k0128g6spcx3mzv6p6-bash-5.1-p16-man
error: path '/nix/store/cqam21jchkwyp7k0128g6spcx3mzv6p6-bash-5.1-p16-man' is not valid

This started to happen around the time when nix 2.18.0 was released. Downgrading to 2.17.0 has resolved this problem.

Steps To Reproduce

  1. clone the daml project: git clone https://github.com/digital-asset/daml.git
  2. cd daml
  3. git checkout 662a4417912df90ba9d9a99817b8ad9703480d06 # not really needed, also fails for commits from 2021
  4. install nix in single-user mode: bash <( curl -sSfL https://nixos.org/nix/install ) --no-daemon
  5. create path_invalid.nix:
with import <nixpkgs> { config = {}; overlays = []; };

let
  # `packages` might include lists, e.g. `stdenv.initialPath` is a list itself,
  # so we need to flatten `packages`.
  flatten = builtins.concatMap (x: if builtins.isList x then x else [x]);
  env = buildEnv {
    name = "posix-toolchain";
    paths = flatten [ stdenv.initialPath ];
  };
  cmd_glob = "${env}/bin/*";
  os = if stdenv.isDarwin then "osx" else "linux";
in

runCommand "bazel-nixpkgs-posix-toolchain"
  { executable = false;
    # Pointless to do this on a remote machine.
    preferLocalBuild = true;
    allowSubstitutes = false;
  }
  ''
    n=$out/nixpkgs_sh_posix.bzl
    mkdir -p "$(dirname "$n")"

    cat >>$n <<EOF
    load("@rules_sh//sh:posix.bzl", "posix", "sh_posix_toolchain")
    discovered = {
    EOF
    for cmd in ${cmd_glob}; do
        if [[ -x $cmd ]]; then
            echo "    \'$(basename $cmd)\': \'$cmd\'," >>$n
        fi
    done
    cat >>$n <<EOF
    }
    def create_posix_toolchain():
        sh_posix_toolchain(
            name = "nixpkgs_sh_posix",
            cmds = {
                cmd: discovered[cmd]
                for cmd in posix.commands
                if cmd in discovered
            }
        )
    EOF
  ''
  1. run:
DADE_NIXPKGS=$(pwd)/nixpkgs-snapshot

if [[ ! -e "$DADE_NIXPKGS" ]]; then
  echo "Loading outdated or missing nixpkgs snapshot..."
  outpath="$(
    nix-store -Q --realise --indirect --add-root "$DADE_NIXPKGS" \
      "$(nix-instantiate -Q --eval "nix/nixpkgs.nix" -A path \
        | sed 's/^\"//;s/\"$//')"
  )"
  echo "Done loading the nixpkgs snapshot to $outpath"
fi
  1. run: NIX_PATH=nixpkgs=$DADE_NIXPKGS nix-build path_invalid.nix

Expected behavior

I would expect the nix-build command to succeed.

nix-env --version output

$ nix-env --version
nix-env (Nix) 2.18.0

Additional context

I have tracked down the error message to

throw InvalidPath("path '%s' is not valid", printStorePath(storePath));

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

🏁 Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions