runner icon indicating copy to clipboard operation
runner copied to clipboard

Running an action via svc start doesn't update runners environment variables - causing failures on jobs

Open tking16 opened this issue 2 years ago • 5 comments

How to reproduce:

method 1:

  1. install and run self-hosted runner on a mac build machine (i.e. ./svc.sh install and ./svc.sh start`)
  2. Add some new items to your $PATH variable
  3. restart your runner so changes take effect with ./svc.sh stop and ./svc.sh start
  4. Run your job that requires the new PATH dependencies

Expected behaviour: New variables added to path can now be accessed via the Action

Actual behaviour: You'll get the same error as the path was not updated for some reason. But if you activate the runner via run.sh then the changes will take effect.

I've worked around this by manually editing the .paths file in actions-runner. But I recently tried the same with my homebrew installation and it isn't working even after updating the path. Is there a saved version of the .zshrc file within the actions-runner folder or something?

tking16 avatar Oct 04 '23 15:10 tking16

Anyone home?

tking16 avatar Dec 06 '23 10:12 tking16

bump

tking16 avatar Dec 22 '23 09:12 tking16

Have you found a solution?

EricB-ADI avatar Apr 22 '24 20:04 EricB-ADI

@EricB-ADI I just created my own function in the svc.sh file:

function refresh() {
    # Github actions is awful so creating a custom func to update env
    source ~/.bash_profile
    source ~/.zshrc
    source ~/.bashrc
    rm -rf .path
    touch .path
    echo $PATH >> .path
    echo "Check path is as expected"
    cat .path
}

Hope that helps

tking16 avatar Apr 30 '24 09:04 tking16

Try to add the env vars to a .env file in the root of your actions-runner service dir and restart the service.

diogomatsubara avatar Sep 19 '24 06:09 diogomatsubara