Build Error at Setup Ruby Stage of Build and Deploy on Actions
Build Error at Setup Ruby Stage of Build and Deploy on Actions

Symptom
The Setup Ruby step fails: the runner "was detected as self-hosted".
Cause
The workflow pinned an old ruby/setup-ruby (v1.161.0) that predates support for current runner images.
Fix
Pin ruby/setup-ruby to v1.195.0 or later.
Applies to
GitHub Actions workflows that set up Ruby, such as Jekyll sites on GitHub Pages
Issue
I recently tried to push updates to my GitHub Pages hosted site (powered by Jekyll Theme) and got the following error at the 'Build' stage.
text
Run ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42
with:
ruby-version: 3.1
bundler-cache: true
cache-version: 0
Error: The current runner (ubuntu-24.04-x64) was detected as self-hosted because the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported).
In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build
You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml
$ ruby-build 3.1.4 /opt/hostedtoolcache/Ruby/3.1.4/x64
Once that completes successfully, mark it as complete with:
$ touch /opt/hostedtoolcache/Ruby/3.1.4/x64.complete
It is your responsibility to ensure installing Ruby like that is not done in parallel.Cause
#596 was released in https://github.com/ruby/setup-ruby/releases/tag/v1.177.0
My workflow is using older version.
Example:
yml
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0Solution
I updated to newer Ruby version:
Example:
yml
uses: ruby/setup-ruby@086ffb1a2090c870a3f881cc91ea83aa4243d408 # v1.195.0