Snyk: incorrect assumptions about patch binary

Created on 11 Oct 2017  路  3Comments  路  Source: snyk/snyk

  • node -v: v8.6.0
  • npm -v: 5.5.1
  • snyk -v: 1.42.6
  • uname -rs: FreeBSD 10.3-STABLE
  • patch -v: patch 2.0-12u10 FreeBSD
  • gpatch -v | head -1: GNU patch 2.7.5 (after pkg install patch)
  • Command run: snyk wizard

Expected behaviour

Patches apply successfully after answering wizard's prompts.

Actual behaviour

Patches fail to apply, --debug reveals the following sort of errors:

  snyk patch command failed [foo] { Error: Command failed: patch -p1 --backup --verbose < /tmp/[foo].snyk-patch --dry-run
patch: unrecognized option `--verbose'
usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory]
             [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count]
             [-r rej-name] [-V t | nil | never] [-x number] [-z backup-ext]
             [--posix] [origfile [patchfile]]
       patch <patchfile

    at ChildProcess.exithandler (child_process.js:271:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:927:16)
    at Socket.stream.socket.on (internal/child_process.js:348:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at Pipe._handle.close [as _onclose] (net.js:547:12)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'patch -p1 --backup --verbose < /tmp/[foo].snyk-patch --dry-run' }  +15ms

Steps to reproduce

  1. Try to use snyk on a FreeBSD machine.

--
Obviously I can work around this by just installing GNU patch and symlinking it to the name snyk expects, but that was not immediately obvious as a requirement of this project in any of the documentation I read. Assuming the output produced by --verbose is needed, should GNU patch be mentioned as a requirement somewhere or even tested for at runtime?

bug

Most helpful comment

A similar thing happens with alpine linux (which is used in a lot of docker images). It uses busybox and the patch command it has available does not have the --backup option. Similar to you, the workaround is to install GNU patch.

All 3 comments

A similar thing happens with alpine linux (which is used in a lot of docker images). It uses busybox and the patch command it has available does not have the --backup option. Similar to you, the workaround is to install GNU patch.

currently snyk outputs Snyk couldn't patch the specified vulnerabilities because GNU's patch is not available. Please install 'patch' and try again. when patch could not be found, especially in Windows environment.

I agree with @welwood08, I suggest the error message to be displayed as well when patch is not the GNU version, even when --debug is not enabled.

:wave: This issue has not had a lot of activity for a while, we are closing. Please re-open if there is anything else further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matmannion picture matmannion  路  3Comments

qmn1711 picture qmn1711  路  4Comments

DanielRuf picture DanielRuf  路  6Comments

Aarbel picture Aarbel  路  6Comments

martintreurnicht picture martintreurnicht  路  5Comments