Globally installed snyk binary is found but not used
My snyk binary is installed globally:
% snyk --version
1.1292.0
However, when performing any actions, the plugin tries to use a local binary that doesn't exist:
> Task :app:snyk-check-binary
Caching disabled for task ':app:snyk-check-binary' because:
Build cache is disabled
Task ':app:snyk-check-binary' is not up-to-date because:
Task has not declared any outputs despite executing actions.
look for standalone binary
no snyk standalone found
Using Snyk CLI version: 1.1292.0 (standalone)
Resolve mutations for :app:snyk-test (Thread[Execution worker,5,main]) started.
:app:snyk-test (Thread[Execution worker,5,main]) started.
> Task :app:snyk-test
Caching disabled for task ':app:snyk-test' because:
Build cache is disabled
Task ':app:snyk-test' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Cannot run program "./snyk": error=2, No such file or directory
Could not execute [report metric STATISTICS_COLLECT_METRICS_OVERHEAD]
Yeah, the culprit is this function
private Optional checkStandAloneVersion() {
log.lifecycle("look for standalone binary");
Runner.Result versionResult;
if (SystemUtil.isWindows()) {
versionResult = Runner.runCommand("snyk.exe -version");
Meta.getInstance().setBinary("snyk.exe");
} else {
versionResult = Runner.runCommand("./snyk -version");
Meta.getInstance().setBinary("./snyk");
}
if (versionResult.failed()) {
log.lifecycle("no snyk standalone found");
return Optional.empty();
}
return Optional.of(versionResult.output.trim());
}
plugin sets local path as global binary regardless of local path being present, the following check for global binary succeeds, but the binary is not unset to use global variant instead.
As a workaround, symlink snyk into current directory
ln "$(which snyk)" snyk
I experience the same bug, it simply can not find ./snyk instead of just snyk
PS. "symlink snyk into current directory" doesn't help as well, since it tries then to find some other files in the project directory
Error: node:internal/modules/cjs/loader:1413 throw err; ^Error: Cannot find module '../wrapper_dist/index.js'Require stack:- /Users/spider.man/Projects/some-project/snyk
at Function._resolveFilename (node:internal/modules/cjs/loader:1410:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
at Function._load (node:internal/modules/cjs/loader:1215:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
at Module.require (node:internal/modules/cjs/loader:1496:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (/Users/spider.man/Projects/some-project/snyk:2:1)
at Module._compile (node:internal/modules/cjs/loader:1740:14) { code: 'MODULE_NOT_FOUND', requireStack: [ '/Users/spider.man/Projects/some-project/snyk' ]}Node.js v23.5.0
Hi, please help to fix this; because the plugin is not usable right now. v0.6.0 has bug of https://github.com/snyk/gradle-plugin/issues/34, while v0.6.1 introduced this bug.