Skip to content

build.sh uses GNU-only date --utc and arch; fails on macOS dev machines #32

@dolph

Description

@dolph

Summary

build.sh uses two GNU-coreutils-only commands:

BUILD_DATE="$(date --utc)"     # GNU date; BSD/macOS date wants `-u`
BUILD_ARCH="$(arch)"           # GNU coreutils; on macOS, `arch` returns "i386" even on Apple Silicon

On macOS:

  • date --utc errors out with usage: date [-jnRu]…. Without set -e already in place, this errors at build time; with set -e (current state), the script aborts.
  • arch exists but reports the kernel arch (i386 for 64-bit, arm64 on M1+). On macOS the canonical Go-style arch comes from uname -m.

This makes build.sh Linux-only despite Go being portable.

Impact (Cross-platform: Low)

Suggested Fix

Replace with portable equivalents:

BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"   # POSIX date -u, ISO 8601
BUILD_OS="$(go env GOOS)"
BUILD_ARCH="$(go env GOARCH)"

go env is always available since this is a Go project, and it returns the same canonical values Go uses internally (linux/darwin/windows × amd64/arm64/…).

Bonus: drop OSTYPE (a bash-only variable) in favor of go env GOOS.

Files

  • build.sh:11-12, 25-26

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions