[GH-ISSUE #2151] .env inconsistently overshadows explicit workflow environment variables #1024

Closed
opened 2026-03-01 21:48:18 +03:00 by kerem · 1 comment
Owner

Originally created by @iby on GitHub (Jan 9, 2024).
Original GitHub issue: https://github.com/nektos/act/issues/2151

Bug report info

act version:            0.2.57
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 14
Docker host:            unix:///Users/iby/.colima/default/docker.sock
Sockets found:
	$HOME/.colima/docker.sock
Config files:           
	/Users/iby/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.21.5
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.57
		DefaultGODEBUG:       panicnil=1
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               arm64
		GOOS:                 darwin
Docker Engine:
	Engine version:        24.0.7
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         systemd
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Ubuntu 23.10
	OS type:               linux
	OS version:            23.10
	OS arch:               aarch64
	OS kernel:             6.5.0-10-generic
	OS CPU:                8
	OS memory:             7925 MB
	Security options:
		name=apparmor
		name=seccomp,profile=builtin
		name=cgroupns

Command used with act

act

Describe issue

By default, act loads dotenv .env file, that can contain MY_VAR variable. The same variable can be defined in global workflow and local step env config:

Global workflow env config Local step env config Dotenv .env file echo $MY_VAR Expected
    123 123
  bar   bar
  bar 123 bar
foo     foo
foo   123 123
foo bar   bar
foo bar 123 bar

When the env variable is explicitly defined in global workflow config, it gets overwritten by dotenv .env file variable, which gets loaded by default – this shouldn't be happening as dotenv variables should not override already defined values.

No response

Workflow content

on:
  push: { branches: [ main ] }

env:
  MY_VAR: foo

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - env:
#          MY_VAR: bar
        run: echo ">>> ${MY_VAR}"

Relevant log output

WARN  ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠  
WARN[0000] unable to get git repo: remote not found     
WARN[0000] unable to get git ref: reference not found   
WARN[0000] unable to get git revision: reference not found 
[main.yml/main] 🚀  Start image=catthehacker/ubuntu:act-latest
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[main.yml/main]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[main.yml/main]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[main.yml/main]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] ⭐ Run Main echo ">>> ${MY_VAR}"
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found
[main.yml/main]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| >>> 123
[main.yml/main]   ✅  Success - Main echo ">>> ${MY_VAR}"
[main.yml/main] Cleaning up container for job main
[main.yml/main] 🏁  Job succeeded
[main.yml/main] unable to get git repo: remote not found
[main.yml/main] unable to get git ref: reference not found
[main.yml/main] unable to get git revision: reference not found

Additional information

No response

Originally created by @iby on GitHub (Jan 9, 2024). Original GitHub issue: https://github.com/nektos/act/issues/2151 ### Bug report info ```plain text act version: 0.2.57 GOOS: darwin GOARCH: arm64 NumCPU: 14 Docker host: unix:///Users/iby/.colima/default/docker.sock Sockets found: $HOME/.colima/docker.sock Config files: /Users/iby/.actrc: -P ubuntu-latest=catthehacker/ubuntu:act-latest -P ubuntu-22.04=catthehacker/ubuntu:act-22.04 -P ubuntu-20.04=catthehacker/ubuntu:act-20.04 -P ubuntu-18.04=catthehacker/ubuntu:act-18.04 Build info: Go version: go1.21.5 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.57 DefaultGODEBUG: panicnil=1 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: arm64 GOOS: darwin Docker Engine: Engine version: 24.0.7 Engine runtime: runc Cgroup version: 2 Cgroup driver: systemd Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Ubuntu 23.10 OS type: linux OS version: 23.10 OS arch: aarch64 OS kernel: 6.5.0-10-generic OS CPU: 8 OS memory: 7925 MB Security options: name=apparmor name=seccomp,profile=builtin name=cgroupns ``` ### Command used with act ```sh act ``` ### Describe issue By default, act loads dotenv `.env` file, that can contain `MY_VAR` variable. The same variable can be defined in global workflow and local step `env` config: Global workflow `env` config | Local step `env` config | Dotenv `.env` file | echo $MY_VAR | Expected -- | -- | -- | -- | --   |   | 123 | 123 | ✅   | bar |   | bar | ✅   | bar | 123 | bar | ✅ foo |   |   | foo | ✅ foo |   | 123 | 123 | ❌ foo | bar |   | bar | ✅ foo | bar | 123 | bar | ✅ When the env variable is explicitly defined in global workflow config, it gets overwritten by dotenv `.env` file variable, which gets loaded by default – this shouldn't be happening as dotenv variables should not override already defined values. ### Link to GitHub repository _No response_ ### Workflow content ```yml on: push: { branches: [ main ] } env: MY_VAR: foo jobs: main: runs-on: ubuntu-latest steps: - env: # MY_VAR: bar run: echo ">>> ${MY_VAR}" ``` ### Relevant log output ```sh WARN ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠ WARN[0000] unable to get git repo: remote not found WARN[0000] unable to get git ref: reference not found WARN[0000] unable to get git revision: reference not found [main.yml/main] 🚀 Start image=catthehacker/ubuntu:act-latest INFO[0000] Parallel tasks (0) below minimum, setting to 1 [main.yml/main] 🐳 docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true INFO[0000] Parallel tasks (0) below minimum, setting to 1 [main.yml/main] 🐳 docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [main.yml/main] 🐳 docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] ⭐ Run Main echo ">>> ${MY_VAR}" [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found [main.yml/main] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir= | >>> 123 [main.yml/main] ✅ Success - Main echo ">>> ${MY_VAR}" [main.yml/main] Cleaning up container for job main [main.yml/main] 🏁 Job succeeded [main.yml/main] unable to get git repo: remote not found [main.yml/main] unable to get git ref: reference not found [main.yml/main] unable to get git revision: reference not found ``` ### Additional information _No response_
kerem 2026-03-01 21:48:18 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 8, 2024):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:2212635999 --> @github-actions[bot] commented on GitHub (Jul 8, 2024): Issue is stale and will be closed in 14 days unless there is new activity
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#1024
No description provided.