[GH-ISSUE #265] runner image does not correctly set environment variables #184

Closed
opened 2026-03-01 21:41:00 +03:00 by kerem · 13 comments
Owner

Originally created by @christopherhesse on GitHub (Jun 4, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/265

When running with act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 the CONDA environment variable is not correctly set:

      - name: whatever
        run: echo $CONDA

On github this outputs:

Run echo $CONDA
  echo $CONDA
  shell: /bin/bash -e {0}
/usr/share/miniconda

Locally it outputs:

[ci/, ubuntu-18.04-1] ⭐  Run whatever
|
[ci/, ubuntu-18.04-1]   ✅  Success - whatever

The file /etc/environment does seem to be present in the nektos/act-environments-ubuntu:18.04 docker image with the correct values, I think it's not being used:

docker run --rm -it --entrypoint "" nektos/act-environments-ubuntu:18.04 cat /etc/environment | grep conda
CONDA=/usr/share/miniconda
Originally created by @christopherhesse on GitHub (Jun 4, 2020). Original GitHub issue: https://github.com/nektos/act/issues/265 When running with `act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04` the `CONDA` environment variable is not correctly set: ``` - name: whatever run: echo $CONDA ``` On github this outputs: ``` Run echo $CONDA echo $CONDA shell: /bin/bash -e {0} /usr/share/miniconda ``` Locally it outputs: ``` [ci/, ubuntu-18.04-1] ⭐ Run whatever | [ci/, ubuntu-18.04-1] ✅ Success - whatever ``` The file `/etc/environment` does seem to be present in the `nektos/act-environments-ubuntu:18.04` docker image with the correct values, I think it's not being used: ``` docker run --rm -it --entrypoint "" nektos/act-environments-ubuntu:18.04 cat /etc/environment | grep conda CONDA=/usr/share/miniconda ```
kerem 2026-03-01 21:41:00 +03:00
Author
Owner

@mk0x9 commented on GitHub (Jul 2, 2020):

Contents of /etc/environment on ubuntu-latest@20200625.0 image in github actions.

PATH="/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin"
ImageVersion=20200625.0
ImageOS=ubuntu18
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar"
HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew"
AZURE_EXTENSION_DIR=/opt/az/azcliextensions
SWIFT_PATH=/usr/share/swift/usr/bin
DOTNET_SKIP_FIRST_TIME_EXPERIENCE="1"
DOTNET_NOLOGO="1"
GECKOWEBDRIVER=/usr/local/share/gecko_driver
CHROME_BIN=/usr/bin/google-chrome
CHROMEWEBDRIVER=/usr/local/share/chrome_driver
JAVA_HOME_7_X64=/usr/lib/jvm/zulu-7-azure-amd64
JAVA_HOME_8_X64=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
JAVA_HOME_11_X64=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64
JAVA_HOME_12_X64=/usr/lib/jvm/adoptopenjdk-12-hotspot-amd64
JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
ANT_HOME=/usr/share/ant
M2_HOME=/usr/share/apache-maven-3.6.3
GRADLE_HOME=/usr/share/gradle
LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.3-standalone.jar
LEIN_HOME=/usr/local/lib/lein
CONDA=/usr/share/miniconda
SELENIUM_JAR_PATH=/usr/share/java/selenium-server-standalone.jar
VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg
DEBIAN_FRONTEND=noninteractive
ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
ANDROID_HOME=/usr/local/lib/android/sdk
GOROOT_1_11_X64=/opt/hostedtoolcache/go/1.11.13/x64
GOROOT_1_12_X64=/opt/hostedtoolcache/go/1.12.17/x64
GOROOT_1_13_X64=/opt/hostedtoolcache/go/1.13.12/x64
GOROOT_1_14_X64=/opt/hostedtoolcache/go/1.14.4/x64
GOROOT=/opt/hostedtoolcache/go/1.14.4/x64
BOOST_ROOT_1_69_0=/opt/hostedtoolcache/boost/1.69.0/x64
BOOST_ROOT_1_72_0=/opt/hostedtoolcache/boost/1.72.0/x64
RUNNER_USER=runner
DEPLOYMENT_BASEPATH=/opt/runner
PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG
PATH=/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
RUNNER_TOOL_CACHE=/opt/hostedtoolcache
POWERSHELL_DISTRIBUTION_CHANNEL=GitHub-Actions-ubuntu18

Contents of /etc/environment on nektos/act-environments-ubuntu:18.04-full@69f4f815404c image:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
ImageVersion=dev
ImageOS=ubuntu18
GECKOWEBDRIVER=/usr/local/share/gecko_driver
GOROOT_1_11_X64=/usr/local/go1.11
GOROOT_1_12_X64=/usr/local/go1.12
GOROOT=/usr/local/go1.12
GOROOT_1_13_X64=/usr/local/go1.13
CHROME_BIN=/usr/bin/google-chrome
CHROMEWEBDRIVER=/usr/local/share/chrome_driver
JAVA_HOME_7_X64=/usr/lib/jvm/zulu-7-azure-amd64
JAVA_HOME_8_X64=/usr/lib/jvm/zulu-8-azure-amd64
JAVA_HOME_11_X64=/usr/lib/jvm/zulu-11-azure-amd64
JAVA_HOME_12_X64=/usr/lib/jvm/zulu-12-azure-amd64
JAVA_HOME=/usr/lib/jvm/zulu-8-azure-amd64
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
ANT_HOME=/usr/share/ant
M2_HOME=/usr/share/apache-maven-3.6.3
GRADLE_HOME=/usr/share/gradle
LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.1-standalone.jar
LEIN_HOME=/usr/local/lib/lein
CONDA=/usr/share/miniconda
PATH=/usr/share/rust/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
SELENIUM_JAR_PATH=/usr/share/java/selenium-server-standalone.jar
VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg
DEBIAN_FRONTEND=noninteractive
ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
ANDROID_HOME=/usr/local/lib/android/sdk
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
BOOST_ROOT_1_69_0=/usr/local/share/boost/1.69.0
BOOST_ROOT=/usr/local/share/boost/1.69.0
<!-- gh-comment-id:653177771 --> @mk0x9 commented on GitHub (Jul 2, 2020): Contents of `/etc/environment` on `ubuntu-latest@20200625.0` image in github actions. ``` PATH="/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" ImageVersion=20200625.0 ImageOS=ubuntu18 AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar" HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew" AZURE_EXTENSION_DIR=/opt/az/azcliextensions SWIFT_PATH=/usr/share/swift/usr/bin DOTNET_SKIP_FIRST_TIME_EXPERIENCE="1" DOTNET_NOLOGO="1" GECKOWEBDRIVER=/usr/local/share/gecko_driver CHROME_BIN=/usr/bin/google-chrome CHROMEWEBDRIVER=/usr/local/share/chrome_driver JAVA_HOME_7_X64=/usr/lib/jvm/zulu-7-azure-amd64 JAVA_HOME_8_X64=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64 JAVA_HOME_11_X64=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 JAVA_HOME_12_X64=/usr/lib/jvm/adoptopenjdk-12-hotspot-amd64 JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64 JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 ANT_HOME=/usr/share/ant M2_HOME=/usr/share/apache-maven-3.6.3 GRADLE_HOME=/usr/share/gradle LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.3-standalone.jar LEIN_HOME=/usr/local/lib/lein CONDA=/usr/share/miniconda SELENIUM_JAR_PATH=/usr/share/java/selenium-server-standalone.jar VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg DEBIAN_FRONTEND=noninteractive ANDROID_SDK_ROOT=/usr/local/lib/android/sdk ANDROID_HOME=/usr/local/lib/android/sdk GOROOT_1_11_X64=/opt/hostedtoolcache/go/1.11.13/x64 GOROOT_1_12_X64=/opt/hostedtoolcache/go/1.12.17/x64 GOROOT_1_13_X64=/opt/hostedtoolcache/go/1.13.12/x64 GOROOT_1_14_X64=/opt/hostedtoolcache/go/1.14.4/x64 GOROOT=/opt/hostedtoolcache/go/1.14.4/x64 BOOST_ROOT_1_69_0=/opt/hostedtoolcache/boost/1.69.0/x64 BOOST_ROOT_1_72_0=/opt/hostedtoolcache/boost/1.72.0/x64 RUNNER_USER=runner DEPLOYMENT_BASEPATH=/opt/runner PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG PATH=/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin RUNNER_TOOL_CACHE=/opt/hostedtoolcache POWERSHELL_DISTRIBUTION_CHANNEL=GitHub-Actions-ubuntu18 ``` Contents of `/etc/environment` on `nektos/act-environments-ubuntu:18.04-full@69f4f815404c` image: ``` PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" ImageVersion=dev ImageOS=ubuntu18 GECKOWEBDRIVER=/usr/local/share/gecko_driver GOROOT_1_11_X64=/usr/local/go1.11 GOROOT_1_12_X64=/usr/local/go1.12 GOROOT=/usr/local/go1.12 GOROOT_1_13_X64=/usr/local/go1.13 CHROME_BIN=/usr/bin/google-chrome CHROMEWEBDRIVER=/usr/local/share/chrome_driver JAVA_HOME_7_X64=/usr/lib/jvm/zulu-7-azure-amd64 JAVA_HOME_8_X64=/usr/lib/jvm/zulu-8-azure-amd64 JAVA_HOME_11_X64=/usr/lib/jvm/zulu-11-azure-amd64 JAVA_HOME_12_X64=/usr/lib/jvm/zulu-12-azure-amd64 JAVA_HOME=/usr/lib/jvm/zulu-8-azure-amd64 JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 ANT_HOME=/usr/share/ant M2_HOME=/usr/share/apache-maven-3.6.3 GRADLE_HOME=/usr/share/gradle LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.1-standalone.jar LEIN_HOME=/usr/local/lib/lein CONDA=/usr/share/miniconda PATH=/usr/share/rust/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin SELENIUM_JAR_PATH=/usr/share/java/selenium-server-standalone.jar VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg DEBIAN_FRONTEND=noninteractive ANDROID_SDK_ROOT=/usr/local/lib/android/sdk ANDROID_HOME=/usr/local/lib/android/sdk AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache BOOST_ROOT_1_69_0=/usr/local/share/boost/1.69.0 BOOST_ROOT=/usr/local/share/boost/1.69.0 ```
Author
Owner

@github-actions[bot] commented on GitHub (Sep 1, 2020):

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

<!-- gh-comment-id:684117441 --> @github-actions[bot] commented on GitHub (Sep 1, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@christopherhesse commented on GitHub (Sep 1, 2020):

Seems like this could still be an issue if /etc/environment is not being executed/used.

<!-- gh-comment-id:685094539 --> @christopherhesse commented on GitHub (Sep 1, 2020): Seems like this could still be an issue if `/etc/environment` is not being executed/used.
Author
Owner

@magneticflux- commented on GitHub (Nov 25, 2020):

I'm running into the same issue using nektos/act-environments-ubuntu:18.04, but with ImageOS:

::error::The environment variable ImageOS must be set

All the environment variables are blank when I try to print them.

<!-- gh-comment-id:733940568 --> @magneticflux- commented on GitHub (Nov 25, 2020): I'm running into the same issue using `nektos/act-environments-ubuntu:18.04`, but with `ImageOS`: ``` ::error::The environment variable ImageOS must be set ``` All the environment variables are blank when I try to print them.
Author
Owner

@catthehacker commented on GitHub (Dec 2, 2020):

It's because /etc/environment is not sourced in Docker containers. You have to source it manually or it has to be done in the image itself. It's not act bug nor limitation.

<!-- gh-comment-id:737082872 --> @catthehacker commented on GitHub (Dec 2, 2020): It's because `/etc/environment` is not sourced in Docker containers. You have to source it manually or it has to be done in the image itself. It's not `act` bug nor limitation.
Author
Owner

@wjdp commented on GitHub (Jan 11, 2021):

I have a step

 14       - uses: ruby/setup-ruby@v1.62.0
 15         with:
 16           ruby-version: 2.5

from https://github.com/wjdp/gotdict/blob/master/.github/workflows/gotdict.yml

On GitHub this works fine. Running via act it fails (firstly with https://github.com/nektos/act/issues/311) and secondly with this issue:

[GOTDict/build] 🚀  Start image=node:12.6-buster-slim
[GOTDict/build]   🐳  docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[GOTDict/build]   🐳  docker cp src=/home/will/local/gotdict/. dst=/github/workspace
[GOTDict/build] ⭐  Run actions/checkout@v2
[GOTDict/build]   ✅  Success - actions/checkout@v2
[GOTDict/build] ⭐  Run ruby/setup-ruby@v1.62.0
[GOTDict/build]   ☁  git clone 'https://github.com/ruby/setup-ruby' # ref=v1.62.0
[GOTDict/build]   🐳  docker cp src=/home/will/.cache/act/ruby-setup-ruby@v1.62.0 dst=/actions/
[GOTDict/build]   ❗  ::error::The environment variable ImageOS must be set
[GOTDict/build]   ❌  Failure - ruby/setup-ruby@v1.62.0
Error: exit with `FAILURE`: 1
<!-- gh-comment-id:757577171 --> @wjdp commented on GitHub (Jan 11, 2021): I have a step ``` 14 - uses: ruby/setup-ruby@v1.62.0 15 with: 16 ruby-version: 2.5 ``` from https://github.com/wjdp/gotdict/blob/master/.github/workflows/gotdict.yml On GitHub this works fine. Running via act it fails (firstly with https://github.com/nektos/act/issues/311) and secondly with this issue: ``` [GOTDict/build] 🚀 Start image=node:12.6-buster-slim [GOTDict/build] 🐳 docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [GOTDict/build] 🐳 docker cp src=/home/will/local/gotdict/. dst=/github/workspace [GOTDict/build] ⭐ Run actions/checkout@v2 [GOTDict/build] ✅ Success - actions/checkout@v2 [GOTDict/build] ⭐ Run ruby/setup-ruby@v1.62.0 [GOTDict/build] ☁ git clone 'https://github.com/ruby/setup-ruby' # ref=v1.62.0 [GOTDict/build] 🐳 docker cp src=/home/will/.cache/act/ruby-setup-ruby@v1.62.0 dst=/actions/ [GOTDict/build] ❗ ::error::The environment variable ImageOS must be set [GOTDict/build] ❌ Failure - ruby/setup-ruby@v1.62.0 Error: exit with `FAILURE`: 1 ```
Author
Owner

@catthehacker commented on GitHub (Jan 11, 2021):

@mk0x9 My message above explains why it fails, to bypass that you can specify OS version in .env file e.g.: ImageOS=ubuntu18 and use it via --env-file

<!-- gh-comment-id:757578778 --> @catthehacker commented on GitHub (Jan 11, 2021): @mk0x9 My message above explains why it fails, to bypass that you can specify OS version in `.env` file e.g.: `ImageOS=ubuntu18` and use it via `--env-file`
Author
Owner

@github-actions[bot] commented on GitHub (Feb 11, 2021):

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

<!-- gh-comment-id:777130303 --> @github-actions[bot] commented on GitHub (Feb 11, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@Warns commented on GitHub (Feb 12, 2021):

@catthehacker Thanks, this worked fine.

I added a .env file in the root directory and referenced it in the related step.

ci.yml

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.2'
        env: 
          --env-file: .env # To satisfy ::error::The environment variable ImageOS must be set
      - uses: maierj/fastlane-action@v2.0.1
        with:
          lane: 'internal'
          subdirectory: 'android'

.env

ImageOS=ubuntu18
<!-- gh-comment-id:778237708 --> @Warns commented on GitHub (Feb 12, 2021): @catthehacker Thanks, this worked fine. I added a `.env` file in the root directory and referenced it in the related step. `ci.yml` ```yaml - uses: ruby/setup-ruby@v1 with: ruby-version: '2.7.2' env: --env-file: .env # To satisfy ::error::The environment variable ImageOS must be set - uses: maierj/fastlane-action@v2.0.1 with: lane: 'internal' subdirectory: 'android' ``` `.env` ```yaml ImageOS=ubuntu18 ```
Author
Owner

@catthehacker commented on GitHub (Feb 12, 2021):

Since act v0.2.19 it's also possible to use just --env ImageOS=ubuntuXX

<!-- gh-comment-id:778313226 --> @catthehacker commented on GitHub (Feb 12, 2021): Since `act` [`v0.2.19`](https://github.com/nektos/act/releases/tag/v0.2.19) it's also possible to use just `--env ImageOS=ubuntuXX`
Author
Owner

@github-actions[bot] commented on GitHub (Mar 16, 2021):

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

<!-- gh-comment-id:799850397 --> @github-actions[bot] commented on GitHub (Mar 16, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@rockandska commented on GitHub (Mar 17, 2021):

It's because /etc/environment is not sourced in Docker containers.

Indeed, but /etc/bash.bashrc is.

You have to source it manually or it has to be done in the image itself.

Having to write specific code in workflows related to the usage of act locally should be avoided IMO.

It's not act bug nor limitation.

Since those variables are available in GitHub Actions, it should be considered as a bug even if there is a workaround like --env ImageOS=ubuntuXX

<!-- gh-comment-id:801097379 --> @rockandska commented on GitHub (Mar 17, 2021): > It's because /etc/environment is not sourced in Docker containers. Indeed, but `/etc/bash.bashrc` is. > You have to source it manually or it has to be done in the image itself. Having to write specific code in workflows related to the usage of act locally should be avoided IMO. > It's not act bug nor limitation. Since those variables are available in GitHub Actions, it should be considered as a bug even if there is a workaround like `--env ImageOS=ubuntuXX`
Author
Owner

@catthehacker commented on GitHub (Mar 17, 2021):

It's because /etc/environment is not sourced in Docker containers.

Indeed, but /etc/bash.bashrc is.

Which doesn't contain anything related to envvars. It shouldn't be used as workaround as well. The proper way is to invoke login shell.

You have to source it manually or it has to be done in the image itself.

Having to write specific code in workflows related to the usage of act locally should be avoided IMO.

That was a workaround.

It's not act bug nor limitation.

Since those variables are available in GitHub Actions, it should be considered as a bug even if there is a workaround like --env ImageOS=ubuntuXX

Missing software related envvars. Not bug.

act not using login shell to update environment. Bug 🐛

Missing ImageOS when running act. Bug 🐛

<!-- gh-comment-id:801177845 --> @catthehacker commented on GitHub (Mar 17, 2021): > > It's because /etc/environment is not sourced in Docker containers. > > Indeed, but `/etc/bash.bashrc` is. Which doesn't contain anything related to envvars. It shouldn't be used as workaround as well. The proper way is to invoke login shell. > > > You have to source it manually or it has to be done in the image itself. > > Having to write specific code in workflows related to the usage of act locally should be avoided IMO. That was a workaround. > > It's not act bug nor limitation. > > Since those variables are available in GitHub Actions, it should be considered as a bug even if there is a workaround like `--env ImageOS=ubuntuXX` Missing software related envvars. Not bug. `act` not using login shell to update environment. Bug 🐛 Missing `ImageOS` when running `act`. Bug 🐛
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#184
No description provided.