【问题标题】:Netlify deployment "failed during stage 'building site': Build script returned non-zero exit code: 42"Netlify 部署“在“构建站点”阶段失败:构建脚本返回非零退出代码:42”
【发布时间】:2019-06-28 23:52:12
【问题描述】:

我尝试将我的 Jekyll 静态站点部署到 Netlify(通过 GitHub),但没有成功。

错误信息是:

"在阶段“建筑工地”期间失败:构建脚本返回非零 退出代码:42"

以下是完整的 Netlify 日志:

5:06:23 PM: Preparing Git Reference refs/heads/master
5:06:23 PM: Starting build script
5:06:23 PM: Installing dependencies
5:06:24 PM: Downloading and installing node v10.16.0...
5:06:25 PM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz...
5:06:25 PM: 
##########################
5:06:25 PM:                            37.2%
5:06:25 PM: 
##########################################
5:06:25 PM:                         58.4%
5:06:25 PM: 
################################################
5:06:25 PM: ######################## 100.0%
5:06:25 PM: Computing checksum with sha256sum
5:06:25 PM: Checksums matched!
5:06:28 PM: Now using node v10.16.0 (npm v6.9.0)
5:06:28 PM: Unknown ruby interpreter version (do not know how to handle): RUBY_VERSION.
5:06:28 PM: Attempting ruby version 2.6.2, read from environment
5:06:29 PM: Using ruby version 2.6.2
5:06:29 PM: Using PHP version 5.6
5:06:29 PM: Started restoring cached ruby gems
5:06:29 PM: Finished restoring cached ruby gems
5:06:29 PM: Installing gem bundle
5:06:30 PM: Warning: the running version of Bundler (2.0.1) is older than the version that created the lockfile (2.0.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
5:06:31 PM: Fetching gem metadata from https://rubygems.org/
5:06:33 PM: Fetching public_suffix 3.1.1
5:06:33 PM: Installing public_suffix 3.1.1
5:06:33 PM: Fetching addressable 2.6.0
5:06:33 PM: Installing addressable 2.6.0
5:06:33 PM: Using bundler 2.0.1
5:06:33 PM: Fetching colorator 1.1.0
5:06:33 PM: Installing colorator 1.1.0
5:06:33 PM: Fetching concurrent-ruby 1.1.5
5:06:33 PM: Installing concurrent-ruby 1.1.5
5:06:33 PM: Fetching eventmachine 1.2.7
5:06:33 PM: Installing eventmachine 1.2.7 with native extensions
5:06:49 PM: Fetching http_parser.rb 0.6.0
5:06:49 PM: Installing http_parser.rb 0.6.0 with native extensions
5:06:50 PM: Fetching em-websocket 0.5.1
5:06:50 PM: Installing em-websocket 0.5.1
5:06:50 PM: Fetching ffi 1.11.1
5:06:51 PM: Installing ffi 1.11.1 with native extensions
5:06:59 PM: Fetching forwardable-extended 2.6.0
5:06:59 PM: Installing forwardable-extended 2.6.0
5:06:59 PM: Fetching i18n 0.9.5
5:06:59 PM: Installing i18n 0.9.5
5:06:59 PM: Fetching rb-fsevent 0.10.3
5:07:00 PM: Installing rb-fsevent 0.10.3
5:07:00 PM: Fetching rb-inotify 0.10.0
5:07:00 PM: Installing rb-inotify 0.10.0
5:07:00 PM: Fetching sass-listen 4.0.0
5:07:00 PM: Installing sass-listen 4.0.0
5:07:00 PM: Fetching sass 3.7.4
5:07:00 PM: Installing sass 3.7.4
5:07:00 PM: Fetching jekyll-sass-converter 1.5.2
5:07:00 PM: Installing jekyll-sass-converter 1.5.2
5:07:00 PM: Fetching ruby_dep 1.5.0
5:07:00 PM: Installing ruby_dep 1.5.0
5:07:00 PM: Fetching listen 3.1.5
5:07:00 PM: Installing listen 3.1.5
5:07:00 PM: Fetching jekyll-watch 2.2.1
5:07:00 PM: Installing jekyll-watch 2.2.1
5:07:00 PM: Fetching kramdown 1.17.0
5:07:01 PM: Installing kramdown 1.17.0
5:07:01 PM: Fetching liquid 4.0.3
5:07:01 PM: Installing liquid 4.0.3
5:07:01 PM: Fetching mercenary 0.3.6
5:07:01 PM: Installing mercenary 0.3.6
5:07:01 PM: Fetching pathutil 0.16.2
5:07:01 PM: Installing pathutil 0.16.2
5:07:01 PM: Fetching rouge 3.5.1
5:07:02 PM: Installing rouge 3.5.1
5:07:02 PM: Fetching safe_yaml 1.0.5
5:07:02 PM: Installing safe_yaml 1.0.5
5:07:02 PM: Fetching jekyll 3.8.5
5:07:02 PM: Installing jekyll 3.8.5
5:07:02 PM: Fetching jekyll-feed 0.12.1
5:07:02 PM: Installing jekyll-feed 0.12.1
5:07:02 PM: Fetching jekyll-paginate 1.1.0
5:07:02 PM: Installing jekyll-paginate 1.1.0
5:07:02 PM: Fetching jekyll-seo-tag 2.6.1
5:07:02 PM: Installing jekyll-seo-tag 2.6.1
5:07:02 PM: Fetching jekyll-sitemap 1.3.1
5:07:05 PM: failed during stage 'building site': Build script returned non-zero exit code: 42
5:07:02 PM: Installing jekyll-sitemap 1.3.1
5:07:02 PM: Bundle complete! 4 Gemfile dependencies, 30 gems now installed.
5:07:02 PM: Bundled gems are installed into `/opt/build/cache/bundle`
5:07:02 PM: Post-install message from sass:
5:07:02 PM: Ruby Sass has reached end-of-life and should no longer be used.

因为日志的最后一条语句是:

Ruby Sass 已终止使用,不应再使用。

我错误地认为 Ruby Sass 是需要解决的问题。附上我的 Gemfile 和 Gemfile.lock(以及 Netlify 日志)后,@JayDorsey 好心地建议(在他下面的回答中)Ruby Sass 不是问题。

最终更新:找到解决方案

在专门搜索 Netlify 错误代码“42”后,我找到了这篇文章 (https://jameshfisher.com/2019/01/09/how-to-fix-activating-bundler-2-failed-error-in-your-jekyll-build/),并立即解决了该错误。

对我有用的解决方案是删除

BUNDLED WITH
   2.0.2

来自我的 Gemfile.lock。

以下是我原来的 Gemfile.lock,你可以注意到它以必须删除的代码结尾:

GEM
  remote: https://rubygems.org/
  specs:
    addressable (2.6.0)
      public_suffix (>= 2.0.2, < 4.0)
    colorator (1.1.0)
    concurrent-ruby (1.1.5)
    em-websocket (0.5.1)
      eventmachine (>= 0.12.9)
      http_parser.rb (~> 0.6.0)
    eventmachine (1.2.7)
    eventmachine (1.2.7-x64-mingw32)
    ffi (1.11.1)
    ffi (1.11.1-x64-mingw32)
    forwardable-extended (2.6.0)
    http_parser.rb (0.6.0)
    i18n (0.9.5)
      concurrent-ruby (~> 1.0)
    jekyll (3.8.5)
      addressable (~> 2.4)
      colorator (~> 1.0)
      em-websocket (~> 0.5)
      i18n (~> 0.7)
      jekyll-sass-converter (~> 1.0)
      jekyll-watch (~> 2.0)
      kramdown (~> 1.14)
      liquid (~> 4.0)
      mercenary (~> 0.3.3)
      pathutil (~> 0.9)
      rouge (>= 1.7, < 4)
      safe_yaml (~> 1.0)
    jekyll-feed (0.12.1)
      jekyll (>= 3.7, < 5.0)
    jekyll-paginate (1.1.0)
    jekyll-sass-converter (1.5.2)
      sass (~> 3.4)
    jekyll-seo-tag (2.6.1)
      jekyll (>= 3.3, < 5.0)
    jekyll-sitemap (1.3.1)
      jekyll (>= 3.7, < 5.0)
    jekyll-watch (2.2.1)
      listen (~> 3.0)
    kramdown (1.17.0)
    liquid (4.0.3)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    mercenary (0.3.6)
    pathutil (0.16.2)
      forwardable-extended (~> 2.6)
    public_suffix (3.1.1)
    rb-fsevent (0.10.3)
    rb-inotify (0.10.0)
      ffi (~> 1.0)
    rouge (3.5.1)
    ruby_dep (1.5.0)
    safe_yaml (1.0.5)
    sass (3.7.4)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)

PLATFORMS
  ruby
  x64-mingw32

DEPENDENCIES
  jekyll-feed
  jekyll-paginate
  jekyll-seo-tag
  jekyll-sitemap

RUBY VERSION
   ruby 2.6.2p47

BUNDLED WITH
   2.0.2

【问题讨论】:

  • 您应该能够在 Gemfile 中查找 sass gem 并将其替换为 sassc,但如果它仅在 Gemfile.lock 文件中,则意味着其他东西依赖于它.你能发布你的 Gemfile.lock 吗?
  • @JayDorsey 刚刚在上面的帖子中包含了我的 Gemfile.lock,非常感谢!
  • 看起来jekyll-sass-converter 具有 sass 依赖项。我查看了文档,根据 github 页面,它依赖于 sassc,而不是 sass。也许bundle update jekyll-sass-converter?您也可以发布您的 Gemfile 吗?还有你的操作系统——你在 Windows 上吗?
  • @JayDorsey 我在 mac mojave 上,我做了捆绑更新(它指出“Bundler 试图更新 jekyll-sass-converter,但它的版本保持不变”)。还包括上面的 Gemfile 和 Netlify 日志。再次感谢!
  • 在同样的情况下,您的解决方案也对我有用。虽然我不喜欢手动修改我的 Gemfile.lock 文件。我想知道 Netlify 是否知道这是一个问题?无论如何感谢您的修复!

标签: ruby rubygems jekyll web-deployment netlify


【解决方案1】:

您看到的错误应该只是一个警告,不应影响部署。我会再次仔细检查 netlify 日志,看看是否还有其他错误。

最新发布版本的jekyll-sass-converter 仍然使用sass gem。看起来他们还没有发布使用sassc 的新版本。

如果您将以下内容添加到您的 Gemfile,然后运行 ​​bundle install,Jekyll 将选择使用 sassc 而不是 sass 的版本,并让您摆脱看到的警告

gem 'jekyll-sass-converter', git: 'https://github.com/jekyll/jekyll-sass-converter', branch: 'master'

如果这不起作用,请先尝试在本地构建您的网站,看看是否有任何错误

【讨论】:

  • 感谢您的帮助@JayDorsey!正如您所提到的,ruby sass 不是问题,我已经找到了部署错误的解决方案。再次感谢! :)
  • 出了什么问题?
  • 嗨,我发现的问题已在“最终更新:找到解决方案”部分下的原始帖子中进行了更新。希望有帮助!
猜你喜欢
  • 2021-02-04
  • 1970-01-01
  • 2020-06-19
  • 2019-10-26
  • 1970-01-01
  • 1970-01-01
  • 2022-06-13
  • 2020-02-19
  • 1970-01-01
相关资源
最近更新 更多