Skip to content

Environment overrides seem to be ignored since 2.6.0 #5491

@sergeymakinen

Description

@sergeymakinen

What happened?

For some reason GoReleaser detects environment variables in overrides but doesn't apply them since version 2.6.0.

goreleaser build --clean --snapshot --verbose on 2.6.1

  • verbose output enabled
  • using configuration                              path=.goreleaser.yml
  • parallelism: 10
  • skipping validate...
  • cleaning distribution directory
  • loading environment variables
  • getting and validating git state
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false rev-parse --abbrev-ref HEAD --quiet] stdout=HEAD
      stderr=
      │ fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
      │ Use '--' to separate paths from revisions, like this:
      │ 'git <command> [<revision>...] -- [<file>...]'
    • ignoring errors because this is a snapshot    
      error=
      │ couldn't get current branch: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
      │ Use '--' to separate paths from revisions, like this:
      │ 'git <command> [<revision>...] -- [<file>...]'
    • git state                                      commit=none branch=none current_tag=v0.0.0 previous_tag=<unknown> dirty=false
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false ls-remote --get-url] stdout= stderr=fatal: No remote configured to list refs from.
    • pre-release for tag v0.0.0 set to false
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false ls-remote --get-url] stdout= stderr=fatal: No remote configured to list refs from.
    • git command result                             args=[-c log.showSignature=false config gpg.program] stdout= stderr=
    • git command result                             args=[-c log.showSignature=false config gpg.program] stdout= stderr=
  • skipped partial
  • snapshotting
    • building snapshot...                           version=0.0.0-SNAPSHOT-none
  • skipped running before hooks
  • ensuring distribution directory
    • dist doesn't exist, creating empty directory
  • setting up metadata
  • writing release metadata
    • writing                                        path=dist/metadata.json
    • added new artifact                             name=metadata.json type=Metadata path=dist/metadata.json
  • loading go mod information
  • build prerequisites
  • skipped checking go.mod
  • skipped proxying go module
  • writing effective configuration                  path=dist/config.yaml
  • building binaries
    • building                                       build={gr-env-override [] [] [] [] [] [] [] [] [] [linux_arm64_v8.0] [] . . gr-env-override {[] []} go    go build  false   { [-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser] [] [] [] [] [CGO_ENABLED=1 CC=unbuildable]} [{linux arm64   v8.0     { [] [] [] [] [] [CGO_ENABLED=0]}}]}
    • building                                       binary=dist/gr-env-override_linux_arm64_v8.0/gr-env-override
    • overridden build details for linux_arm64_v8.0  details={ [-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser] [] [] [] [] [CC=unbuildable CGO_ENABLED=0]}
    • env "CGO_ENABLED=1" evaluated to "CGO_ENABLED=1"
    • env "CC=unbuildable" evaluated to "CC=unbuildable"
    • executing                                      cmd=go
  ⨯ build failed after 0s                   
    error=
    │ build failed: failed to build for linux_arm64_v8.0: exit status 1: # runtime/cgo
    │ cgo: C compiler "unbuildable" not found: exec: "unbuildable": executable file not found in $PATH
    │ target: linux_arm64_v8.0

goreleaser build --clean --snapshot --verbose on 2.5.1

  • verbose output enabled
  • using configuration                              path=.goreleaser.yml
  • parallelism: 10
  • skipping validate...
  • cleaning distribution directory
  • loading environment variables
  • getting and validating git state
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false rev-parse --abbrev-ref HEAD --quiet] stdout=HEAD stderr=fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
    • ignoring errors because this is a snapshot     error=couldn't get current branch: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
    • git state                                      commit=none branch=none current_tag=v0.0.0 previous_tag=<unknown> dirty=false
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false ls-remote --get-url] stdout= stderr=fatal: No remote configured to list refs from.
    • pre-release for tag v0.0.0 set to false
    • git command result                             args=[-c log.showSignature=false rev-parse --is-inside-work-tree] stdout=true stderr=
    • git command result                             args=[-c log.showSignature=false ls-remote --get-url] stdout= stderr=fatal: No remote configured to list refs from.
    • git command result                             args=[-c log.showSignature=false config gpg.program] stdout= stderr=
    • git command result                             args=[-c log.showSignature=false config gpg.program] stdout= stderr=
  • skipped partial
  • snapshotting
    • building snapshot...                           version=0.0.0-SNAPSHOT-none
  • skipped running before hooks
  • ensuring distribution directory
    • dist doesn't exist, creating empty directory
  • setting up metadata
  • writing release metadata
    • writing                                        path=dist/metadata.json
    • added new artifact                             name=metadata.json type=Metadata path=dist/metadata.json
  • loading go mod information
  • build prerequisites
  • skipped checking go.mod
  • skipped proxying go module
  • writing effective configuration                  path=dist/config.yaml
  • building binaries
    • building                                       build={gr-env-override [] [] [] [] [] [] [] [] [] [linux_arm64_v8.0] [] . . gr-env-override {[] []} go    go build  false   { [-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser] [] [] [] [] [CGO_ENABLED=1 CC=unbuildable]} [{linux arm64   v8.0     { [] [] [] [] [] [CGO_ENABLED=0]}}]}
    • building                                       binary=dist/gr-env-override_linux_arm64_v8.0/gr-env-override
    • overridden build details for linux_arm64_v8.0  details={ [-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser] [] [] [] [] [CC=unbuildable CGO_ENABLED=0]}
    • env "CC=unbuildable" evaluated to "CC=unbuildable"
    • env "CGO_ENABLED=0" evaluated to "CGO_ENABLED=0"
    • running
    • added new artifact                             name=gr-env-override type=Binary path=dist/gr-env-override_linux_arm64_v8.0/gr-env-override
  • skipped universal binaries
  • skipped signing binaries
  • skipped sign & notarize macOS binaries
  • skipped upx
  • skipped size reports
  • writing artifacts metadata
    • writing                                        path=dist/artifacts.json
  • build succeeded after 0s
  • thanks for using GoReleaser!

How can we reproduce this?

.goreleaser.yml

version: 2

builds:
  - env:
      - CGO_ENABLED=1
      - CC=unbuildable
    targets:
      - linux_arm64
    overrides:
      - goos: linux
        goarch: arm64
        goarm64: v8.0
        env:
          - CGO_ENABLED=0

main.go

package main

func main() {}

cgo.go

package main

import "C"

//export myadd
func myadd(a C.int, b C.int) C.int {
	return a + b
}

goreleaser version

____       ____      _
 / ___| ___ |  _ \ ___| | ___  __ _ ___  ___ _ __
| |  _ / _ \| |_) / _ \ |/ _ \/ _` / __|/ _ \ '__|
| |_| | (_) |  _ <  __/ |  __/ (_| \__ \  __/ |
 \____|\___/|_| \_\___|_|\___|\__,_|___/\___|_|
goreleaser: Release engineering, simplified.
https://goreleaser.com

GitVersion:    2.6.1
GitCommit:     b6bb03ddc28d6de71a37012107cda26af53cc116
GitTreeState:  clean
BuildDate:     2025-01-22T11:11:07
BuiltBy:       homebrew
GoVersion:     go1.23.5
Compiler:      gc
ModuleSum:     unknown
Platform:      darwin/arm64

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this

Supporter

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

Metadata

Metadata

Assignees

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