Skip to content

Regression: markers which are not strings cause eval errors #1909

@lf-

Description

@lf-

Describe the issue

Regression in #1905 cc @jamesdbrock @Nebucatnetzer

With a lock file entry like:

[[package]]
name = "colorama"
version = "0.4.6"
description = "Cross-platform colored terminal text."
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
groups = ["main", "dev"]
files = [
    {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
    {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]
markers = {main = "platform_system == \"Windows\"", dev = "sys_platform == \"win32\""}

The markers will cause an evaluation error:

       … while calling the 'listToAttrs' builtin
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:270:29:
          269|             # Null out any filtered packages, we don't want python.pkgs from nixpkgs
          270|             (_final: _prev: builtins.listToAttrs (builtins.map (x: { name = normalizePackageName x.name; value = nul
l; }) incompatible))
             |                             ^
          271|             # Create poetry2nix layer

       … while calling the 'map' builtin
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:270:51:
          269|             # Null out any filtered packages, we don't want python.pkgs from nixpkgs
          270|             (_final: _prev: builtins.listToAttrs (builtins.map (x: { name = normalizePackageName x.name; value = nul
l; }) incompatible))
             |                                                   ^
          271|             # Create poetry2nix layer

       … while evaluating an expression to select 'wrong' on it
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:193:22:
          192|       compatible = partitions.right;
          193|       incompatible = partitions.wrong;
             |                      ^
          194|

       … while calling the 'partition' builtin
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:191:9:
          190|         in
          191|         lib.partition supportsPythonVersion poetryLock.package;
             |         ^
          192|       compatible = partitions.right;

       … while calling 'supportsPythonVersion'
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:182:35:
          181|         let
          182|           supportsPythonVersion = pkgMeta:
             |                                   ^
          183|             if pkgMeta ? markers then

       … from call site
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:188:17:
          187|                 in
          188|                 pyproject-nix.lib.pep508.evalMarkers pep508Env marker
             |                 ^
          189|               ) else true && poetryLib.checkPythonVersions pyVersion pkgMeta.python-versions;

       … while calling 'evalMarkers'
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:763:14:
          762|   evalMarkers =
          763|     environ: value:
             |              ^
          764|     (

       … while evaluating a branch condition
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:765:7:
          764|     (
          765|       if value.type == "compare" then
             |       ^
          766|         (

       … while evaluating an expression to select 'type' on it
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:765:10:
          764|     (
          765|       if value.type == "compare" then
             |          ^
          766|         (

       … from call site
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/default.nix:186:28:
          185|                 let
          186|                   marker = pyproject-nix.lib.pep508.parseMarkers pkgMeta.markers;
             |                            ^
          187|                 in

       … while calling anonymous lambda
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:250:5:
          249|     in
          250|     input:
             |     ^
          251|     if input == "" then

       … from call site
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:429:7:
          428|       in
          429|       reduceValue { } groupedTokens;
             |       ^
          430|

       … while calling 'reduceValue'
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:351:17:
          350|         reduceValue =
          351|           lhs': value:
             |                 ^
          352|           if isList value then

       … while evaluating a branch condition
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:352:11:
          351|           lhs': value:
          352|           if isList value then
             |           ^
          353|             (

       … while calling the 'isList' builtin
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:352:14:
          351|           lhs': value:
          352|           if isList value then
             |              ^
          353|             (

       … while evaluating a branch condition
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:347:25:
          346|         # We can completely avoid it if the input doesn't contain any grouped subexpressions.
          347|         groupedTokens = if any (token: token == "(") tokens then groupTokens [ ] 0 else tokens;
             |                         ^
          348|

       … while calling the 'any' builtin
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:347:28:
          346|         # We can completely avoid it if the input doesn't contain any grouped subexpressions.
          347|         groupedTokens = if any (token: token == "(") tokens then groupTokens [ ] 0 else tokens;
             |                            ^
          348|

       … while evaluating a branch condition
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:314:11:
          313|         tokens =
          314|           if tokens'.start == cmax && last != " " then tokens'.tokens ++ [ last ] else tokens'.tokens;
             |           ^
          315|

       … in the left operand of the AND (&&) operator
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:314:36:
          313|         tokens =
          314|           if tokens'.start == cmax && last != " " then tokens'.tokens ++ [ last ] else tokens'.tokens;
             |                                    ^
          315|

       … while evaluating an expression to select 'start' on it
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:314:14:
          313|         tokens =
          314|           if tokens'.start == cmax && last != " " then tokens'.tokens ++ [ last ] else tokens'.tokens;
             |              ^
          315|

       … while calling the 'foldl'' builtin
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:263:11:
          262|         tokens' =
          263|           foldl'
             |           ^
          264|             (acc: c: rec {

       … from call site
         at /nix/store/sc7ip1wzp6madcvjv82abx91a1fcrnfa-source/vendor/pyproject.nix/lib/pep508.nix:255:17:
          254|       let
          255|         chars = stringToCharacters input;
             |                 ^
          256|         cmax = (length chars) - 1;

       … while calling 'stringToCharacters'
         at /nix/store/8hzp2ran0rqixlk37rfdyq4jpnmf3b6a-source/lib/strings.nix:898:24:
          897|   */
          898|   stringToCharacters = s:
             |                        ^
          899|     genList (p: substring p 1 s) (stringLength s);

       … while calling the 'genList' builtin
         at /nix/store/8hzp2ran0rqixlk37rfdyq4jpnmf3b6a-source/lib/strings.nix:899:5:
          898|   stringToCharacters = s:
          899|     genList (p: substring p 1 s) (stringLength s);
             |     ^
          900|

       … while evaluating the second argument passed to builtins.genList

       … while calling the 'stringLength' builtin
         at /nix/store/8hzp2ran0rqixlk37rfdyq4jpnmf3b6a-source/lib/strings.nix:899:35:
          898|   stringToCharacters = s:
          899|     genList (p: substring p 1 s) (stringLength s);
             |                                   ^
          900|

       … while evaluating the argument passed to builtins.stringLength

       error: cannot coerce a set to a string: { dev = "sys_platform == \"win32\""; main = "platform_system == \"Windows\""; }

Additional context

default.nix/shell.nix/flake.nix:
Sorry, it is proprietary :( I can write up a reproducer later when I get time; either this is enough info to find it or I can write a reproducer in a few hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions