Skip to content

Variant environment variables take precedence over environment variables of a package  #186

Open
@filiptronicek

Description

@filiptronicek

Bug description

When you use variants with leeway and specify and environment variable and have a package which also specifies the same environment variable, the variant's setting will be preferred.

I believe this to be a bug because a package is more specific than a variant (although they're not directly related) and in our case in https://github.com/gitpod-io/gitpod it let to unexpected behavior with a global setting for GOARCH and our inability to override it inside a package building our CLI for different platforms.

Steps to reproduce

WORKSPACE.yaml:

defaultVariant:
  env:
    - GOARCH=amd64

BUILD.yaml:

packages:
  - name: env-test
    type: generic
    env:
      - GOARCH=arm64
      - GOOS=darwin
    config:
      commands:
        - ["sh", "-c", "echo $GOARCH $GOOS && exit 1"]

Expected behavior

Building the above results in arm64 darwin instead of the actual amd64 darwin.

Example repository

No response

Anything else?

It may not be clear-cut what of the two should actually have preference over the other and if it's the case there's no common agreement, I can also see a possibility for a leeway package to specify its own default variant or other opt-out of global settings.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions