【问题标题】:What are the dependencies of `gatsby-plugin-sharp` and `mozjpeg`?`gatsby-plugin-sharp` 和 `mozjpeg` 的依赖关系是什么?
【发布时间】:2021-06-05 16:08:49
【问题描述】:

gatsby-plugin-sharp(或更具体的子依赖关系mozjpeg)存在问题,它会给出异常autoreconf: not found,但问题实际上在于其他依赖关系。在许多帖子中,人们已经找到了各种依赖项的一种或另一种组合以使其为他们工作(例如https://stackoverflow.com/a/66170062/2475012https://github.com/gatsbyjs/gatsby/issues/19432#issuecomment-553644600)。但是,您需要的确切依赖项似乎没有一个明确的列表。

我正在ubuntu-latest 上的 GitHub Actions 上运行 Gatsby。我的package.json

{
  "name": "matt.si",
  "private": false,
  "description": "Mattsi Jansky's personal blog",
  "author": "Mattsi Jansky",
  "scripts": {
    "build": "gatsby build",
    "dev": "gatsby develop",
    "test": "jest",
    "test:updateSnapshots": "jest --updateSnapshot",
    "test:visual": "yarn build && ./scripts/run-visual-regression-tests.sh",
    "test:visual:update": "docker-compose run visual-regression-tests reference",
    "test:visual:approve": "docker-compose run visual-regression-tests approve",
    "test:visual:report": "open tests/visual/backstop_data/html_report/index.html",
    "lint": "eslint --ext .js,.jsx --ignore-pattern public ."
  },
  "dependencies": {
    "babel-preset-gatsby": "0.5.1",
    "gatsby": "2.24.87",
    "gatsby-image": "2.4.21",
    "gatsby-plugin-feed": "2.5.19",
    "gatsby-plugin-google-analytics": "2.3.19",
    "gatsby-plugin-manifest": "2.4.35",
    "gatsby-plugin-offline": "3.2.37",
    "gatsby-plugin-react-helmet": "3.3.14",
    "gatsby-plugin-sass": "2.3.21",
    "gatsby-plugin-sharp": "3.0.0",
    "gatsby-remark-footnotes": "0.0.7",
    "gatsby-remark-images": "3.3.39",
    "gatsby-remark-prismjs": "3.5.16",
    "gatsby-source-filesystem": "2.3.36",
    "gatsby-transformer-remark": "2.8.46",
    "gatsby-transformer-sharp": "2.5.20",
    "identity-obj-proxy": "3.0.0",
    "node-sass": "4.14.1",
    "prismjs": "1.22.0",
    "prop-types": "15.7.2",
    "react": "16.14.0",
    "react-dom": "16.14.0",
    "react-helmet": "6.1.0",
    "react-test-renderer": "16.14.0",
    "rehype-react": "6.1.0"
  },
  "devDependencies": {
    "babel-jest": "26.6.1",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.5",
    "eslint": "7.12.0",
    "eslint-plugin-react": "7.21.5",
    "jest": "26.6.1",
    "wait-on": "5.2.0"
  },
  "license": "GPL-3.0-only"
}

GitHub Actions 定义的相关部分:

name: Run tests
on: [push]

jobs:
  build:
    name: Run Tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      
      - name: Install System Dependencies
        run: sudo apt-get update && sudo apt-get install make nasm autoconf automake libtool dpkg pkg-config libpng-dev g++

      - name: Install Project Dependencies
        uses: borales/actions-yarn@v2.1.0
        with:
          cmd: install

它在Install Project Dependencies 步骤中以autoreconf: not found 失败。我尝试将autoreconf 添加到Install System Dependencies 步骤,但它已经是最新版本。我试过buildessentials,但它也已经是最新版本了。我添加了libvips-dev,这似乎是apt-getlibvips 库的名称,并且确实安装了那个。在使用mozjpeg (https://stackoverflow.com/a/64927666/2475012) 查找相同的问题后,我添加了sudo apt-get install make nasm autoconf automake libtool dpkg pkg-config libpng-dev g++。但除nasm 之外的所有这些都已经存在。

但每次我仍然遇到autoreconf: not found 问题。具体来说,完整的错误(https://github.com/Mattsi-Jansky/matt.si/runs/2051073618):

[4/4] Building fresh packages...
error /github/workspace/node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /github/workspace/node_modules/mozjpeg
Output:
⚠ spawn /github/workspace/node_modules/mozjpeg/vendor/cjpeg ENOENT
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c autoreconf -fiv
/bin/sh: autoreconf: not found


    at /github/workspace/node_modules/bin-build/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 0)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

所以我很茫然。我想我的问题是:a)我是否在这里遵循正确的线程,试图找到正确的依赖项? b) 我应该添加哪些依赖项?

【问题讨论】:

    标签: gatsby github-actions sharp mozjpeg


    【解决方案1】:

    已通过将 borales/actions-yarn 的用法替换为 setup node(包括 Yarn)来解决此问题。

    borales/actions-yarn 用于 GitHub Actions 测试版,不是运行 yarn 操作的推荐方式。它们以某种传统方式运行。我不太清楚细节,但我认为发生的事情是borales/actions-yarn 运行在没有安装依赖项的单独映像上。

    【讨论】:

      【解决方案2】:

      【讨论】:

      • 我认为这还不完整。这些是 NPM 知道的所有依赖项,但在mozjpeg 的安装步骤中,它会尝试编译依赖于主机上的许多库和构建工具的东西。如makenasmautoconfautomakelibtooldpkgpkg-configlibpng-devg++。这些是您无法安装 mozjpeg 的依赖项,但它们不是 NPM 依赖项。
      • 这是 NPM 包所说的,这不是一个完整的问题,是 NPM 文档本身所说的......这些是辅助依赖项,可能是其他模块或开发依赖项本身所必需的。你能再澄清一下问题的范围吗?
      • 它们是您无法成功安装 mozjpeg 的依赖项。 NPM 可能已经解决了它的依赖关系,但是当mozjpeg 的安装后脚本被调用时,它会尝试从源代码构建自己并失败。我可以在网上找到的大多数信息表明这是由于缺少从源代码构建所需的构建依赖项。特别是因为我们在错误输出中看到了compiling from source,所以这里肯定出错了:github.com/imagemin/mozjpeg-bin/blob/…
      猜你喜欢
      • 2019-04-02
      • 2019-09-25
      • 1970-01-01
      • 2014-10-29
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 2015-04-28
      相关资源
      最近更新 更多