FlamingTempura / bibtex-tidy

Cleaner and Formatter for BibTeX files
https://flamingtempura.github.io/bibtex-tidy/
MIT License
859 stars 66 forks source link

pre-commit.ci fails to install with npm's `--dev` dependencies. #427

Closed bdice closed 1 month ago

bdice commented 6 months ago

I would like to use this repository's pre-commit hooks with pre-commit.ci. However, it looks like this is not possible because the development dependencies include puppeteer which installs Chromium (if I'm reading this correctly). Here is the log. https://results.pre-commit.ci/run/github/168426142/1711990670.ELxuaVPpR1CviNOJqJh8Kw

This behavior broke between v1.8.5 → v1.11.0.

build attempt 1...
    => error
    [INFO] Installing environment for https://github.com/FlamingTempura/bibtex-tidy.
    [INFO] Once installed this environment will be reused.
    [INFO] This may take a few minutes...
    An unexpected error has occurred: CalledProcessError: command: ('/pc/clone/XfjFjNt7Squa3kp4KYxEog/node_env-system/bin/node', '/opt/node/bin/npm', 'install', '--dev', '--prod', '--ignore-prepublish', '--no-progress', '--no-save')
    return code: 1
    stdout: (none)
    stderr:
        npm WARN config dev Please use --include=dev instead.
        npm WARN config production Use `--omit=dev` instead.
        npm notice 
        npm notice New major version of npm available! 9.6.7 -> 10.5.0
        npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>
        npm notice Run `npm install -g npm@10.5.0` to update!
        npm notice 
        npm ERR! code 1
        npm ERR! path /pc/clone/XfjFjNt7Squa3kp4KYxEog/node_modules/puppeteer
        npm ERR! command failed
        npm ERR! command sh -c node install.js
        npm ERR! ERROR: Failed to set up Chromium r1108766! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
        npm ERR! [Error: ENOENT: no such file or directory, mkdir '/src/.cache'] {
        npm ERR!   errno: -2,
        npm ERR!   code: 'ENOENT',
        npm ERR!   syscall: 'mkdir',
        npm ERR!   path: '/src/.cache'
        npm ERR! }

        npm ERR! A complete log of this run can be found in: /tmp/npm/_logs/2024-04-01T17_00_39_617Z-debug-0.log
    Check the log at /pc/pre-commit.log
build attempt 2...
    => error
    [INFO] Installing environment for https://github.com/FlamingTempura/bibtex-tidy.
    [INFO] Once installed this environment will be reused.
    [INFO] This may take a few minutes...
    An unexpected error has occurred: CalledProcessError: command: ('/pc/clone/XfjFjNt7Squa3kp4KYxEog/node_env-system/bin/node', '/opt/node/bin/npm', 'install', '--dev', '--prod', '--ignore-prepublish', '--no-progress', '--no-save')
    return code: 1
    stdout: (none)
    stderr:
        npm WARN config dev Please use --include=dev instead.
        npm WARN config production Use `--omit=dev` instead.
        npm ERR! code 1
        npm ERR! path /pc/clone/XfjFjNt7Squa3kp4KYxEog/node_modules/puppeteer
        npm ERR! command failed
        npm ERR! command sh -c node install.js
        npm ERR! ERROR: Failed to set up Chromium r1108766! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
        npm ERR! [Error: ENOENT: no such file or directory, mkdir '/src/.cache'] {
        npm ERR!   errno: -2,
        npm ERR!   code: 'ENOENT',
        npm ERR!   syscall: 'mkdir',
        npm ERR!   path: '/src/.cache'
        npm ERR! }

        npm ERR! A complete log of this run can be found in: /tmp/npm/_logs/2024-04-01T17_00_49_364Z-debug-0.log
    Check the log at /pc/pre-commit.log
njzjz commented 6 months ago

I encountered the same issue. As a workaround, I created a new repository mirrors-bibtex-tidy which doesn't need to install the development dependencies.

  - repo: https://github.com/njzjz/mirrors-bibtex-tidy
    rev: v1.11.0
    hooks:
      - id: bibtex-tidy

I can transfer it to the author of bibtex-tidy if the author would like to maintain it.

FlamingTempura commented 6 months ago

Thanks @njzjz. A PR for this would be most welcome.

FlamingTempura commented 1 month ago

Fixed in v1.14.0 (kind of)

It's not possible to disable installing dev dependencies when using language:node, that's a limitation of pre-commit. I've instead changed pre-commit to use language:script. This won't do any npm install, but it also depends on node being installed on the user's system. Seems like an acceptable limitation for now, as it's easier to install node than workaround the problem originally reported here.

Closing this as fixed.