ruby / setup-ruby

An action to download a prebuilt Ruby and add it to the PATH in 5 seconds

Home Page:https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jankeesvw opened this issue · comments

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! ✨

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`
}

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).

        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.

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?

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?

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 ✨

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?

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

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.