rattler-build icon indicating copy to clipboard operation
rattler-build copied to clipboard

bug(variants): empty string variants not processed correctly

Open lucascolley opened this issue 6 months ago โ€ข 10 comments

openblas-feedstock on ๐ŸŽ‹ rattler [๐ŸŽญโฌ†๏ธ ] via ๐Ÿงš v0.48.2 
โฏ bat recipe/variants.yaml 
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
       โ”‚ File: recipe/variants.yaml
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1   โ”‚ zip_keys:
   2   โ”‚   - [SYMBOLSUFFIX, name_suffix, INTERFACE64]
   3   โ”‚ 
   4   โ”‚ # gcc 12 cannot handle `-mtune=native` on aarch,
   5   โ”‚ # gcc 13 causes test failures on ppc
   6   โ”‚ c_compiler_version:
   7   โ”‚   - if: linux
   8   โ”‚     then: 14
   9   โ”‚ fortran_compiler_version:
  10   โ”‚   - if: linux
  11   โ”‚     then: 14
  12   โ”‚ 
  13   โ”‚ SYMBOLSUFFIX:
  14   โ”‚   - ""
  15   โ”‚   - if: not (win or aarch64)
  16   โ”‚     then: "64_"
  17   โ”‚ 
  18   โ”‚ name_suffix:
  19   โ”‚   - ""
  20   โ”‚   - if: not (win or aarch64)
  21   โ”‚     then: "-ilp64"
  22   โ”‚ 
  23   โ”‚ INTERFACE64:
  24   โ”‚   - 0
  25   โ”‚   - if: not (win or aarch64)
  26   โ”‚     then: 1
  27   โ”‚ 
  28   โ”‚ USE_OPENMP:
  29   โ”‚   - if: not osx
  30   โ”‚     then: "0"
  31   โ”‚   - "1"
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

openblas-feedstock on ๐ŸŽ‹ rattler [โœ˜๐ŸŽญ?] via ๐Ÿงš v0.48.2
โฏ pixi run rerender
...
Error:   ร— Zip key elements do not all have same length: INTERFACE64

openblas-feedstock on ๐ŸŽ‹ rattler [โฌ†๏ธ ] via ๐Ÿงš v0.48.2 took 4s 
โฏ git diff
diff --git a/recipe/variants.yaml b/recipe/variants.yaml
index 8903f69..cfecacc 100644
--- a/recipe/variants.yaml
+++ b/recipe/variants.yaml
@@ -11,12 +11,12 @@ fortran_compiler_version:
     then: 14
 
 SYMBOLSUFFIX:
-  - ""
+  - "foo"
   - if: not (win or aarch64)
     then: "64_"
 
 name_suffix:
-  - ""
+  - "bar"
   - if: not (win or aarch64)
     then: "-ilp64"

openblas-feedstock on ๐ŸŽ‹ rattler [๐Ÿ”จโฌ†๏ธ ] via ๐Ÿงš v0.48.2 
โฏ pixi run rerender
... // no error

lucascolley avatar Jun 26 '25 12:06 lucascolley

Interesting. It's possible that we remove empty strings like this as if they would not exist.

wolfv avatar Jun 26 '25 12:06 wolfv

yeah, I'm looking for a fix now

lucascolley avatar Jun 26 '25 12:06 lucascolley

It looks like the problem is in the initial parsing, by the time we get to https://github.com/prefix-dev/rattler-build/blob/5baeaf1bf3ea58e52c3a7b5ce3ffcb51711f1974/src/variant_config.rs#L572-L596 the empty strings are already dropped from the RenderedNodes:

2025-06-26T12:32:20.602508Z DEBUG Finding outputs from recipe: rattler_build::variant_config: "SYMBOLSUFFIX"
2025-06-26T12:32:20.602518Z DEBUG Finding outputs from recipe: rattler_build::variant_config: Sequence(
    RenderedSequenceNode {
        value: [
            Scalar(
                RenderedScalarNode {
                    value: "64_",
                },
            ),
        ],
    },
)
2025-06-26T12:32:20.602527Z DEBUG Finding outputs from recipe: rattler_build::variant_config: Some(
    [
        "64_",
    ],
)
2025-06-26T12:32:20.602532Z DEBUG Finding outputs from recipe: rattler_build::variant_config: "name_suffix"
2025-06-26T12:32:20.602535Z DEBUG Finding outputs from recipe: rattler_build::variant_config: Sequence(
    RenderedSequenceNode {
        value: [
            Scalar(
                RenderedScalarNode {
                    value: "-ilp64",
                },
            ),
        ],
    },
)
2025-06-26T12:32:20.602591Z DEBUG Finding outputs from recipe: rattler_build::variant_config: Some(
    [
        "-ilp64",
    ],
)
2025-06-26T12:32:20.602608Z DEBUG Finding outputs from recipe: rattler_build::variant_config: "INTERFACE64"
2025-06-26T12:32:20.602612Z DEBUG Finding outputs from recipe: rattler_build::variant_config: Sequence(
    RenderedSequenceNode {
        value: [
            Scalar(
                RenderedScalarNode {
                    value: "0",
                },
            ),
            Scalar(
                RenderedScalarNode {
                    value: "1",
                },
            ),
        ],
    },
)

lucascolley avatar Jun 26 '25 12:06 lucascolley

Possibly related:

Error: 
  ร— expected a scalar value.
    โ•ญโ”€[recipe/recipe.yaml:11:17]
 10 โ”‚   # ILP64_string: ${{ "" if SYMBOLSUFFIX != "64_" else " (ILP64 interface) " }}
 11 โ”‚   ILP64_string: ""
    ยท                 โ”€โ”ฌ
    ยท                  โ•ฐโ”€โ”€ here
 12 โ”‚   name_suffix: ""
    โ•ฐโ”€โ”€โ”€โ”€
  help: `context` values must always be scalars (booleans, integers or strings) or uniform lists of scalars

lucascolley avatar Jun 26 '25 12:06 lucascolley

switching to ${{ "" }} I see

yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/new:ruamel.yaml.scalarstring.DoubleQuotedScalarString'

EDIT: perhaps a different problem, I seem to see this after removing all ${{ "" }}

lucascolley avatar Jun 26 '25 12:06 lucascolley

rattler-build build works fine with a local conda_build_config.yaml. However, rattler-build build -m fails with the following yaml dumped by rattler_build_conda_compat:

{'python': ['3.12'], 'numpy': ['1.26'], 'perl': ['5.26.2'], 'lua': ['5'], 'r_base': ['3.5'], 'cpu_optimization_target': ['nocona'], 'pin_run_as_build': {'python': {'min_pin': 'x.x', 'max_pin': 'x.x'}, 'r-base': {'min_pin': 'x.x', 'max_pin': 'x.x'}}, 'ignore_version': [], 'ignore_build_only_deps': ['python', 'numpy'], 'extend_keys': ['extend_keys', 'ignore_build_only_deps', 'pin_run_as_build', 'ignore_version'], 'cran_mirror': ['https://cran.r-project.org'], 'target_platform': ['linux-64'], 'c_compiler': ['gcc'], 'cxx_compiler': ['gxx'], 'fortran_compiler': ['gfortran'], 'c_compiler_version': ['14'], 'fortran_compiler_version': ['14'], 'SYMBOLSUFFIX': ['', '64_'], 'name_suffix': ['', '-ilp64'], 'INTERFACE64': ['0', '1'], 'USE_OPENMP': ['0', '1'], 'zip_keys': [['SYMBOLSUFFIX', 'name_suffix', 'INTERFACE64']], 'c_stdlib': ['sysroot'], 'c_stdlib_version': ['2.17']}

that yaml does include the empty string variants, so the problem is hit some time after rattler-build reading the yaml

lucascolley avatar Jun 30 '25 12:06 lucascolley

correct at https://github.com/prefix-dev/rattler-build/blob/d18bacf0a77d5595b63256b6ad299b72e807089c/src/variant_config.rs#L258

            ScalarNode {
                value: "name_suffix",
            }: Sequence(
                SequenceNode {
                    value: [
                        Simple(
                            Scalar(
                                ScalarNode {
                                    value: "",
                                },
                            ),
                        ),
                        Simple(
                            Scalar(
                                ScalarNode {
                                    value: "-ilp64",
                                },
                            ),
                        ),
                    ],
                },
            ),

incorrect at https://github.com/prefix-dev/rattler-build/blob/d18bacf0a77d5595b63256b6ad299b72e807089c/src/variant_config.rs#L260

            RenderedScalarNode {
                value: "name_suffix",
            }: Sequence(
                RenderedSequenceNode {
                    value: [
                        Scalar(
                            RenderedScalarNode {
                                value: "-ilp64",
                            },
                        ),
                    ],
                },
            ),

lucascolley avatar Jun 30 '25 14:06 lucascolley

https://github.com/prefix-dev/rattler-build/blob/d18bacf0a77d5595b63256b6ad299b72e807089c/src/recipe/custom_yaml/rendered.rs#L663-L686 returns a Null node for an empty string variant.

@wolfv do you know if empty ScalarNodes are widely used as null values? https://github.com/prefix-dev/rattler-build/blob/d18bacf0a77d5595b63256b6ad299b72e807089c/src/recipe/custom_yaml.rs#L379-L382 seems to suggest that "null" would be an alternative.

lucascolley avatar Jun 30 '25 15:06 lucascolley

implementing a stricter is_empty for RenderedScalarNode at gh-1764 fixes the immediate issue, but breaks other things

lucascolley avatar Jun 30 '25 17:06 lucascolley

I closed the linked PR as I won't have time to look into it further, but maybe it was going in the right direction, so worth taking a look at if somebody else wants to try tackling this issue

lucascolley avatar Sep 22 '25 11:09 lucascolley