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

Load needed variant values before first render

Open wolfv opened this issue 1 year ago • 1 comments

Validation and variant are sometimes a bit tricky.

If you have a recipe like this:

package:
  name: foo
  version: ${{ FOO_VERSION }}

with a variants.yaml like so:

FOO_VERSION:
- "0.1.0"
- "0.2.0"

The recipe rendering will fail with something like:

Error:   × Parsing: missing field `version`
    ╭─[7:7]
  6 │     package:
  7 │ ╭─▶   name: clang-win-activation
  8 │ │     version: ${{ CLANG_VERSION }}
  9 │ │   
 10 │ ├─▶ build:
    · ╰──── add the field `version` in between here
 11 │       number: 0
    ╰────
  help: the field `version` is required for `package`

Because we don't inject the variant values early enough.

Similarly, the following fails:

requirements:
  run:
    - foo ${{ FOO_VERSION }}.*

With an error of the sort:

Error:   × Parsing: failed to parse match spec: Unable to parse version spec: .*
    ╭─[18:7]
 17 │   run:
 18 │     - foo ${{ FOO_VERSION }}.*
    ·       ──────────────┬─────────────
    ·                     ╰── error parsing `foo .*` as a match spec
 19 │   run_exports:
    ╰────

wolfv avatar Aug 07 '24 06:08 wolfv

Would love this for running tests in pixi with interesting custom channels

ruben-arts avatar Oct 03 '24 08:10 ruben-arts

The second one is actually fixed. The first one is not an issue IMO (users should write their recipes differently, e.g. by using ${{ env.get("FOO_VERSION" }}.

wolfv avatar May 02 '25 15:05 wolfv