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

The environment variable ImageOS must be set (Self hosted runner) #230

Closed
jankeesvw opened this issue Nov 11, 2021 · 9 comments
Closed

The environment variable ImageOS must be set (Self hosted runner) #230

jankeesvw opened this issue Nov 11, 2021 · 9 comments

Comments

@jankeesvw
Copy link
Contributor

We are trying to use setup-ruby on a self hosted runner but we get this error:

The environment variable ImageOS must be set

I tried all kinds of things but I can't get it working, this is our current yml file for our actions.

name: tests

on: [ push ]

jobs:
  cleanup:
    runs-on: self-hosted
    steps:
      - uses: rokroskar/workflow-run-cleanup-action@master
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

  rubocop:
    runs-on: self-hosted

    steps:
      - uses: actions/checkout@v1

      - name: Set up Ruby 3.0.2
        if: steps.changes.outputs.stekkerweb == 'true'
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.0.2
        env:
          ImageOS: ubuntu20

I see a mention of this issue in the readme, but it does not tell me what to do. Can someone give me a pointer on how to fix this?

Thanks! ✨

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Nov 11, 2021

Maybe try ubuntu-20.04? See https://github.com/actions/virtual-environments#available-environments.

Not sure whether (or how) one can define different platforms with self-hosted runners...

Can you add a step before the 'ruby/setup-ruby@v1' step and output the ENV variable?

EDIT: @eregon is correct (my mistake). Code here (below) parses ImageOS so it matches the yaml runs-on: values...

setup-ruby/common.js

Lines 101 to 107 in f20f1ea

export function getVirtualEnvironmentName() {
const imageOS = getImageOS()
let match = imageOS.match(/^ubuntu(\d+)/) // e.g. ubuntu18
if (match) {
return `ubuntu-${match[1]}.04`
}

@eregon
Copy link
Member

eregon commented Nov 11, 2021

I think https://github.com/ruby/setup-ruby#using-self-hosted-runners is clear, you need to set ImageOS on the self-hosted runner, otherwise this action has no idea how to find out which OS and OS version you are using.

Of course the value must be what the runner is actually using, otherwise it's unsupported (Ruby is prebuilt on a set of OS & versions, on other OS it just doesn't work it would need to be rebuilt).

@eregon eregon closed this as completed Nov 11, 2021
@eregon
Copy link
Member

eregon commented Nov 11, 2021

        env:
          ImageOS: ubuntu20

should work though, do you have a log of the failed build, or better a public URL of such a failed build?

The env var should be set by the runner ideally, not in the workflow.

@eregon eregon reopened this Nov 11, 2021
@jankeesvw
Copy link
Contributor Author

I think https://github.com/ruby/setup-ruby#using-self-hosted-runners is clear, you need to set ImageOS on the self-hosted runner, otherwise this action has no idea how to find out which OS and OS version you are using.

This sounds very simple, if you know what to do, but I honestly have no idea how to do this. Do I define this in the .yml or on the host?

Can you give me a tiny pointer @eregon?

@jankeesvw
Copy link
Contributor Author

The env var should be set by the runner ideally, not in the workflow.

Can you tell me where I define this env variable so the runner picks this up on a self hosted system?

@jankeesvw
Copy link
Contributor Author

Thanks for the pointers, I've found this file ~/actions-runner/.env

Changed the content, now it works!

gh-actions@github-runner-4:~/actions-runner$ cat .env
LANG=C.UTF-8
ImageOS=ubuntu20

Home this issue will help someone in the future ✨

@eregon
Copy link
Member

eregon commented Nov 12, 2021

Glad you found it, I actually didn't know the details, I never had time to mess with self-hosted runners yet.
PR to improve that section of the README welcome.

Also, maybe this is something that should maybe be automatically set when installing the runner on a machine, and so worth filing an issue to https://github.com/actions/runner?

@jankeesvw
Copy link
Contributor Author

Glad you found it, I actually didn't know the details, I never had time to mess with self-hosted runners yet. PR to improve that section of the README welcome.

Also, maybe this is something that should maybe be automatically set when installing the runner on a machine, and so worth filing an issue to https://github.com/actions/runner?

I created a PR: #232

@SevenOperations
Copy link

Self hosted runners support other operating systems. We use enterprise linux here. What do we need to put for the ImageOS variable for OS's other than ubuntu, mac and windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants