Ruby and Rails Github动作出口代码16
我正在尝试与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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
[问题固定]
解决方案:
运行
捆绑锁-ADD-PLATFORM X86_64-LINUX
[ISSUE FIXED]
Solution:
Run
bundle lock --add-platform x86_64-linux
tl; dr
运行此命令本地在您的项目中进行更改
为什么起作用?
Gerard Morera 和 wael的答案穆罕默德是正确的。其中有更多详细信息:
考虑Ruby的以下GitHub操作配置:
配置声明
Ubuntu-latest
平台图像用于在GitHub操作上运行作业。github操作使用
x86_64-Linux
ubuntu平台。但是,gemfile.lock
缺少导致出口代码16的平台。在本地运行以下命令将添加
x86_64-linux
平台到gemfile.lock :
运行命令后,最终
gemfile.lock
看起来与此相似:x86_64-linux
现在在Platforms 列表中添加
gemfile.lock
,因此它将在github操作的Ubuntu图像上正确运行。TL;DR
Run this command locally in your project and commit the changes
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:
The config declares
ubuntu-latest
platform image for running the job on Github Actions.Github Actions uses
x86_64-linux
platform for ubuntu. However, theGemfile.lock
is missing that platform leading to exit code 16.Running the following command locally will add
x86_64-linux
platform toGemfile.lock
:After running the command, the final
Gemfile.lock
looks similar to this:The
x86_64-linux
is now added underPLATFORMS
list inGemfile.lock
, therefore it will run correctly on ubuntu images of Github Actions.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.