Ruby and Rails Github动作出口代码16

发布于 2025-01-31 05:29:19 字数 1379 浏览 5 评论 0原文

我正在尝试与GitHub动作建立一个连续的集成工作流程,以用于新的Rails项目。这是错误:

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)

配置文件:

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

有人知道问题是什么吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慵挽 2025-02-07 05:29:19

[问题固定]

解决方案:

运行捆绑锁-ADD-PLATFORM X86_64-LINUX

[ISSUE FIXED]

Solution:

Run bundle lock --add-platform x86_64-linux

饮惑 2025-02-07 05:29:19

tl; dr

运行此命令本地在您的项目中进行更改

bundle lock --add-platform x86_64-linux

为什么起作用?

Gerard Morera wael的答案穆罕默德是正确的。其中有更多详细信息:

考虑Ruby的以下GitHub操作配置:

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

配置声明Ubuntu-latest平台图像用于在GitHub操作上运行作业。
github操作使用x86_64-Linux ubuntu平台。但是,gemfile.lock缺少导致出口代码16的平台。

在本地运行以下命令将添加x86_64-linux平台到gemfile.lock :

bundle lock --add-platform x86_64-linux

运行命令后,最终gemfile.lock看起来与此相似:

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

DEPENDENCIES
  fastlane
...

x86_64-linux现在在Platforms 列表中添加gemfile.lock,因此它将在github操作的Ubuntu图像上正确运行。

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.

苏佲洛 2025-02-07 05:29:19

Gerard Morera提供的答案对我来说很好。但是,我花了一段时间才意识到我需要通过项目中的powershell/命令行运行bundle lock -add-platform x86_64-linux(这是我的jekyll项目/站点案件)。

在我的情况下出现此问题的原因是,我在Windows 10上捆绑了该网站,而Linux驱动的机器处理部署(由GitHub工作流触发/控制),这也可能会有所帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文