[GH-ISSUE #784] Provide option to disable loading .env file by default #492

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

Originally created by @nenadfilipovic on GitHub (Aug 22, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/784

System information

  • Operating System: Linux
  • Architecture: x64
  • Apple M1: /
  • Docker version: /
  • Docker image used in act: /
  • act version: 0.2.24

Expected behaviour

Please provide a way to disable loading .env file as default.

Actual behaviour

Act loads .env file as default, my workflow does not use environment vars, it uses only secrets. I was banging my head whole day why my workflow does not fail even when I comment out environment object inside workflow. My app needs these values and with those values commented out my app would still build and that would never happen inside GitHub actions workflow, it would fail every time.

Example:

name: Continuous integration

on:
  pull_request:
    branches:
      - main
    paths-ignore:
      - '**/*.md'

env:
#   POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
#   POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }}
#   POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
#   POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
#   POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}

This would work perfectly fine and when pushed to GitHub CI it would fail.

Workflow and/or repository

/

Steps to reproduce

Provide environment for whole workflow and hydrate it from secrets, when executed act will load .env and you will get fake impression that everything works and your app wont ask for other environment vars.

I provided --env-file .fake.env inside .actrc to prevent it from loading my .env file.
In this configuration I get these warnings and that would never happen if I let act load .env file:

WARNING: The HOST variable is not set. Defaulting to a blank string.
WARNING: The APP_PORT variable is not set. Defaulting to a blank string.
WARNING: The APP_HOSTNAME variable is not set. Defaulting to a blank string.
WARNING: The INFLUXDB_USER variable is not set. Defaulting to a blank string.
WARNING: The INFLUXDB_PASSWORD variable is not set. Defaulting to a blank string.

act output

/

Originally created by @nenadfilipovic on GitHub (Aug 22, 2021). Original GitHub issue: https://github.com/nektos/act/issues/784 ## System information - Operating System: Linux - Architecture: x64 - Apple M1: / - Docker version: / - Docker image used in `act`: / - `act` version: 0.2.24 ## Expected behaviour Please provide a way to disable loading .env file as default. ## Actual behaviour Act loads `.env` file as default, my workflow does not use environment vars, it uses only secrets. I was banging my head whole day why my workflow does not fail even when I comment out environment object inside workflow. My app needs these values and with those values commented out my app would still build and that would never happen inside GitHub actions workflow, it would fail every time. Example: ```yml name: Continuous integration on: pull_request: branches: - main paths-ignore: - '**/*.md' env: # POSTGRES_DB: ${{ secrets.POSTGRES_DB }} # POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }} # POSTGRES_USER: ${{ secrets.POSTGRES_USER }} # POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} # POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} ``` This would work perfectly fine and when pushed to GitHub CI it would fail. ## Workflow and/or repository / ## Steps to reproduce Provide environment for whole workflow and hydrate it from secrets, when executed act will load `.env` and you will get fake impression that everything works and your app wont ask for other environment vars. I provided `--env-file .fake.env` inside .actrc to prevent it from loading my .env file. In this configuration I get these warnings and that would never happen if I let act load .env file: ``` WARNING: The HOST variable is not set. Defaulting to a blank string. WARNING: The APP_PORT variable is not set. Defaulting to a blank string. WARNING: The APP_HOSTNAME variable is not set. Defaulting to a blank string. WARNING: The INFLUXDB_USER variable is not set. Defaulting to a blank string. WARNING: The INFLUXDB_PASSWORD variable is not set. Defaulting to a blank string. ``` ## `act` output /
kerem 2026-03-01 21:43:52 +03:00
  • closed this issue
  • added the
    kind/bug
    label
Author
Owner

@catthehacker commented on GitHub (Aug 22, 2021):

act --env-file=""

<!-- gh-comment-id:903292684 --> @catthehacker commented on GitHub (Aug 22, 2021): `act --env-file=""`
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#492
No description provided.