Ger*_*era 20 continuous-integration ruby-on-rails github-actions
我正在尝试为新的 Rails 项目设置一个带有 Github 操作的持续集成工作流程。这是错误:
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)
Run Code Online (Sandbox Code Playgroud)
以及配置文件:
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
Run Code Online (Sandbox Code Playgroud)
有人知道问题是什么吗?
Dr.*_*ton 11
长话短说
在项目本地运行此命令并提交更改
bundle lock --add-platform x86_64-linux
Run Code Online (Sandbox Code Playgroud)
为什么这有效?
Gerard Morera和Wael Mohammed的答案是正确的。这里有更多细节:
考虑以下 Ruby 的 Github Actions 配置:
...
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
...
Run Code Online (Sandbox Code Playgroud)
该配置声明了ubuntu-latest用于在 Github Actions 上运行作业的平台映像。Github Actions 使用x86_64-linuxubuntu 平台。但是,Gemfile.lock缺少该平台导致退出代码 16。
在本地运行以下命令会将x86_64-linux平台添加到Gemfile.lock:
bundle lock --add-platform x86_64-linux
Run Code Online (Sandbox Code Playgroud)
运行命令后,最终结果Gemfile.lock类似于:
...
PLATFORMS
universal-darwin-22
x64-mingw32
x86_64-linux
DEPENDENCIES
fastlane
...
Run Code Online (Sandbox Code Playgroud)
x86_64-linux现在已添加PLATFORMS到 中的列表下,因此它将Gemfile.lock在 Github Actions 的 ubuntu 映像上正确运行。
小智 8
杰拉德·莫雷拉(Gerard Morera)提供的答案对我来说效果很好;然而,我花了一段时间才意识到我需要bundle lock --add-platform x86_64-linux从项目内通过 PowerShell/命令行运行(在我的案例中这是一个 Jekyll 项目/站点)。
强调一下,在我的案例中出现此问题的原因是,我在 Windows 10 上捆绑该网站,而 Linux 驱动的计算机处理部署(由 GitHub 工作流程触发/控制),这可能也会有所帮助。
| 归档时间: |
|
| 查看次数: |
6012 次 |
| 最近记录: |