23

I am trying to set up a continuous integration workflow with Github actions for a new Rails project. This is the error:

2022-05-21T17:07:01.1242737Z Your bundle only supports platforms ["x86_64-darwin-19", "x86_64-darwin-21"] but
2022-05-21T17:07:01.1243516Z your local platform is x86_64-linux. Add the current platform to the lockfile
2022-05-21T17:07:01.1244782Z with `bundle lock --add-platform x86_64-linux` and try again.
2022-05-21T17:07:01.1294935Z Took   1.38 seconds
2022-05-21T17:07:01.1295823Z ##[endgroup]
2022-05-21T17:07:01.1347744Z ##[error]Error: The process '/opt/hostedtoolcache/Ruby/3.1.2/x64/bin/bundle' failed with exit code 16
    at ExecState._setResult (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:4918:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:4901:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:4795:27)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

And the configuration file:

name: My workflow
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        bundler-cache: true
    - run: bundle exec rake

Does anybody know what the issue is?

1
  • Gerard, please select an answer. Commented Jan 25, 2023 at 3:20

3 Answers 3

38

[ISSUE FIXED]

Solution:

Run bundle lock --add-platform x86_64-linux

Sign up to request clarification or add additional context in comments.

Comments

14

TL;DR

Run this command locally in your project and commit the changes

bundle lock --add-platform x86_64-linux

Why does this work?

The answers from Gerard Morera and Wael Mohammed are correct. Here's more detail to it:

Considering the following Github Actions config for Ruby:

...
  unit-test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: '3.0'
        bundler-cache: true
...

The config declares ubuntu-latest platform image for running the job on Github Actions. Github Actions uses x86_64-linux platform for ubuntu. However, the Gemfile.lock is missing that platform leading to exit code 16.

Running the following command locally will add x86_64-linux platform to Gemfile.lock:

bundle lock --add-platform x86_64-linux

After running the command, the final Gemfile.lock looks similar to this:

...
PLATFORMS
  universal-darwin-22
  x64-mingw32
  x86_64-linux

DEPENDENCIES
  fastlane
...

The x86_64-linux is now added under PLATFORMS list in Gemfile.lock, therefore it will run correctly on ubuntu images of Github Actions.

Comments

9

The answer provided by Gerard Morera worked fine for me; however, it took me a while to realise that I needed to run bundle lock --add-platform x86_64-linux via PowerShell/command line from within the project (it was a Jekyll project/site on my case).

It may also be helpful to highlight that the reason this issue appeared in my case was that I was bundling the site on Windows 10 while a Linux-powered machine handled the deployment (triggered/controlled by a GitHub workflow.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.