Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
filiptronicek opened this issue Jul 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@filiptronicek
Copy link
Member

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.

@filiptronicek filiptronicek added the bug Something isn't working label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant