Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self hosted runners remove HOME variable from the enviroment #1864

Closed
tcowan opened this issue May 1, 2022 · 6 comments
Closed

Self hosted runners remove HOME variable from the enviroment #1864

tcowan opened this issue May 1, 2022 · 6 comments
Assignees
Labels
awaiting-customer-response bug Something isn't working

Comments

@tcowan
Copy link

tcowan commented May 1, 2022

Describe the bug
HOME variable is missing from the environment

To Reproduce
Steps to reproduce the behavior:

  1. Create a script that runs 'set' on Linux to print the entire environment
  2. Create a yaml file in your repo that executes the above script
  3. Notice that the HOME variable is missing

Expected behavior
My scripts rely on the accurate contents of $HOME

Runner Version and Platform

Version of your runner?
2.290.1

OS of the machine running the runner?
Ubuntu 20.04.03

What's not working?

HOME environment variable is not present in the environment
Please include error messages and screenshots.

Entire output of set command:

CI='true'
GITHUB_ACTION='__run'
GITHUB_ACTIONS='true'
GITHUB_ACTION_REF=''
GITHUB_ACTION_REPOSITORY=''
GITHUB_ACTOR='tcowan'
GITHUB_API_URL='https://api.github.com/'
GITHUB_BASE_REF=''
GITHUB_ENV='/home/actions/runners/cs3030/_work/_temp/_runner_file_commands/set_env_36b20bb6-9450-460b-8e44-dcd24dbc1526'
GITHUB_EVENT_NAME='push'
GITHUB_EVENT_PATH='/home/actions/runners/cs3030/_work/_temp/_github_workflow/event.json'
GITHUB_GRAPHQL_URL='https://api.github.com/graphql'
GITHUB_HEAD_REF=''
GITHUB_JOB='Explore-GitHub-Actions'
GITHUB_PATH='/home/actions/runners/cs3030/_work/_temp/_runner_file_commands/add_path_36b20bb6-9450-460b-8e44-dcd24dbc1526'
GITHUB_REF='refs/heads/master'
GITHUB_REF_NAME='master'
GITHUB_REF_PROTECTED='false'
GITHUB_REF_TYPE='branch'
GITHUB_REPOSITORY='cowancs3030summer22/lab1-tcowan'
GITHUB_REPOSITORY_OWNER='cowancs3030summer22'
GITHUB_RETENTION_DAYS='90'
GITHUB_RUN_ATTEMPT='13'
GITHUB_RUN_ID='2251804981'
GITHUB_RUN_NUMBER='2'
GITHUB_SERVER_URL='https://github.com/'
GITHUB_SHA='5416fbe7c1e303a441c9bc7da2cbdbb832b374f4'
GITHUB_STEP_SUMMARY='/home/actions/runners/cs3030/_work/_temp/_runner_file_commands/step_summary_36b20bb6-9450-460b-8e44-dcd24dbc1526'
GITHUB_WORKFLOW='GitHub Actions Demo'
GITHUB_WORKSPACE='/home/actions/runners/cs3030/_work/lab1-tcowan/lab1-tcowan'
IFS='
'
INVOCATION_ID='119dbd1c0bb6424d90654555e762316b'
JOURNAL_STREAM='8:1311471131'
LANG='en_US.UTF-8'
LANGUAGE='en_US:en'
LC_ALL='en_US.UTF-8'
LC_TIME='en_IN.UTF-8'
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
PPID='3416874'
PS1='# '
PS2='> '
PS4='+ '
PWD='/home/actions/runners/cs3030/_work/lab1-tcowan/lab1-tcowan'
RUNNER_ARCH='X64'
RUNNER_NAME='cowancs3030summer22'
RUNNER_OS='Linux'
RUNNER_TEMP='/home/actions/runners/cs3030/_work/_temp'
RUNNER_TOOL_CACHE='/home/actions/runners/cs3030/_work/_tool'
RUNNER_TRACKING_ID='github_c0d6565d-47db-468f-935e-5c675ff30c36'
RUNNER_WORKSPACE='/home/actions/runners/cs3030/_work/lab1-tcowan'
SHLVL='1'
_='/usr/local/bin/cs3030actions'

Job Log Output

If applicable, include the relevant part of the job / step log output here. All sensitive information should already be masked out, but please double-check before pasting here.

Runner and Worker's Diagnostic Logs

If applicable, add relevant diagnostic log information. Logs are located in the runner's _diag folder. The runner logs are prefixed with Runner_ and the worker logs are prefixed with Worker_. Each job run correlates to a worker log. All sensitive information should already be masked out, but please double-check before pasting here.

@freef4ll
Copy link

freef4ll commented May 4, 2022

I think it is good to double check that the HOME exists on the runner process:

actions@8ef62a84e884:~$ strings /proc/$(pgrep -f Runner.Listener)/environ
PWD=/home/actions
HOME=/home/actions
SHLVL=0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=./externals/node16/bin/node

@nikola-jokic nikola-jokic self-assigned this May 5, 2022
@cmurcott-corigine
Copy link

I hit a similar issue recently, which may be related to this one. Following @freef4ll's suggestion, the Runner.Listener process did not contain HOME -

# sudo strings /proc/$(pgrep -f Runner.Listener)/environ
PWD=/home/<runner-user>/actions-runner
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=./externals/node12/bin/node#1326

I found that the Runner.Listener process was running as root, which seemed strange -

# ps axo user,comm | grep Runner.Listener
root     Runner.Listener

It seems that the runner service may have been installed as the root user at some point, affecting the ENV variables available to the process. I managed to resolve the issue by running,

cd /home/<runner-user>/actions-runner  # Or whatever your runner path may be
sudo ./svc-sh uninstall
sudo ./svc-sh install <runner-user>  # Explicitly specify user, not required if running as <runner-user>
sudo ./svc-sh start

sudo rm -rf _diag _work  # Certain files created by root, <runner-user> lacked permissions

@nikola-jokic
Copy link
Contributor

Hey @tcowan,

Can you please confirm that the HOME variable is actually available to the runner based on the suggestions?

Thank you @cmurcott-corigine and @freef4ll for providing answers!

@nikola-jokic
Copy link
Contributor

I'm going to close out this issue until we hear back from you, please let us know if you are still seeing this issue!

@robertglonek
Copy link

Confirming self-hosted runner on AWS ubuntu-latest, no $HOME defined.

@DenisBalan
Copy link

Same, ubuntu based self hosted doesnt have HOME defined out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-customer-response bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants