gitpod-io / gitpod-io/leeway

Variant environment variables take precedence over environment variables of a package

Open
#186 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
183
Forks
27
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with the WORKSPACE.yaml and BUILD.yaml examples, focusing on how variant and package environment variables are combined. Determine the agreed precedence or opt-out behavior, then verify the example produces the documented result and that the behavior is covered by an appropriate regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.