Skip to content

snyk-cli/1.1297.0 package update #53299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

octo-sts[bot]
Copy link
Contributor

@octo-sts octo-sts bot commented May 14, 2025

@octo-sts octo-sts bot added request-version-update request for a newer version of a package automated pr bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages. auto-approver-bot/initial-checks-failed labels May 14, 2025
@developer-guy developer-guy force-pushed the wolfictl-299ce554-3a40-47b9-9a94-c5bc893c520e branch from 13ec9d0 to 1f5e8f5 Compare May 15, 2025 19:35
Copy link
Contributor Author

octo-sts bot commented May 15, 2025

📦 Build Failed: Missing Dependency

Module not found: Error: Can't resolve '@snyk/fix' in '/home/build/src/cli/commands/fix'

Build Details

Category Details
Build System Node.js/webpack
Failure Point webpack build process during 'npm run build-cli:prod'

Root Cause Analysis 🔍

The build is failing because it can't find the '@snyk/fix' module that it depends on. The error occurs during the webpack bundling process. The build step 'npm run build-cli:prod' is failing because webpack cannot resolve the '@snyk/fix' dependency in the 'src/cli/commands/fix' directory, despite it appearing to be included in the workspace packages earlier in the build process.


🔍 Build failure fix suggestions

Found similar build failures that have been fixed in the past and analyzed them to suggest a fix:

Suggested Changes

File: package.yaml

  • modify at line After git checkout steps (pipeline section)
    Original:
  - runs: |
      # Write our version so `make build` doesn't produce an incorrectly-bumped one
      echo "${{package.version}}" > binary-releases/version
      mkdir ts-cli-binaries
      echo "${{package.version}}" > ts-cli-binaries/version
      make build

Replacement:

  - runs: |
      # Install dependencies before building
      npm ci
      
      # Write our version so `make build` doesn't produce an incorrectly-bumped one
      echo "${{package.version}}" > binary-releases/version
      mkdir ts-cli-binaries
      echo "${{package.version}}" > ts-cli-binaries/version
      make build

Content:

Add npm ci command to install dependencies before running make build

File: package.yaml

  • add at line After git checkout steps (Alternative approach - modified pipeline section)
    Original:
  - runs: |
      # Write our version so `make build` doesn't produce an incorrectly-bumped one
      echo "${{package.version}}" > binary-releases/version
      mkdir ts-cli-binaries
      echo "${{package.version}}" > ts-cli-binaries/version
      make build

Replacement:

  - runs: |
      # Install and build dependencies
      npm ci
      
      # Specifically build the @snyk/fix package if it's a workspace package
      if [ -d "packages/fix" ]; then
        cd packages/fix
        npm run build
        cd ../..
      fi
      
      # Write our version so `make build` doesn't produce an incorrectly-bumped one
      echo "${{package.version}}" > binary-releases/version
      mkdir ts-cli-binaries
      echo "${{package.version}}" > ts-cli-binaries/version
      make build

Content:

Add npm ci command and explicit build of @snyk/fix package if it exists
Click to expand fix analysis

Analysis

The build is failing during the webpack bundling process because it can't find the '@snyk/fix' module. This is a dependency resolution issue during the webpack build process. The error specifically occurs in the /home/build/src/cli/commands/fix directory when the 'npm run build-cli:prod' command is executed.

Looking at the Melange YAML and build process, I notice a few key issues:

  1. The build appears to be missing a step to install dependencies with npm/yarn
  2. The '@snyk/fix' package is likely a workspace package or internal dependency that needs to be built or linked before the main build process
  3. The build process goes straight from git checkout to running make build without proper dependency installation
Click to expand fix explanation

Explanation

The error "Module not found: Error: Can't resolve '@snyk/fix' in '/home/build/src/cli/commands/fix'" indicates that during the webpack bundling process, the build system can't find a dependency called '@snyk/fix' that is required by the code in the 'src/cli/commands/fix' directory.

This is a common issue in Node.js projects, especially those with workspaces or monorepo setups, where dependencies need to be properly installed and potentially built before the main application can be built.

The suggested fix adds an npm ci step before attempting to run the main build process. This ensures that all dependencies defined in the package.json (including workspace packages) are properly installed. The npm ci command is preferred over npm install in CI environments as it ensures consistent installations based on the package-lock.json file.

In the Snyk CLI repository, '@snyk/fix' is likely an internal package within the monorepo that needs to be properly linked or built before the main webpack build can reference it. By running npm ci, we ensure all dependencies are correctly installed and linked within the workspace.

If the '@snyk/fix' package requires a build step of its own (which is common for TypeScript packages), we also offer an alternative approach that explicitly builds this package before the main build process.

The 'make build' command may already include dependency installation steps, but since we're seeing this specific error, it suggests that this step might be missing or failing. Adding an explicit installation step before running 'make build' ensures that all prerequisites are met.

Click to expand alternative approaches

Alternative Approaches

  • Update the Melange YAML to use a different build command that ensures proper dependency installation, such as replacing 'make build' with the actual npm scripts that handle both dependency installation and building.
  • Add a specific npm workspace dependency resolution step like 'npm run build:workspaces' or similar if such a script exists in the Snyk CLI repository.
  • Check if there are version constraints for the @snyk/fix package and explicitly add it as a dependency with a fixed version in the package.json.

Was this comment helpful? Please use 👍 or 👎 reactions on this comment.

@octo-sts octo-sts bot added the ai/skip-comment Stop AI from commenting on PR label May 15, 2025
@developer-guy developer-guy force-pushed the wolfictl-299ce554-3a40-47b9-9a94-c5bc893c520e branch from 1f5e8f5 to 8aeb7db Compare May 15, 2025 19:45
Signed-off-by: Batuhan Apaydin <[email protected]>
@developer-guy developer-guy force-pushed the wolfictl-299ce554-3a40-47b9-9a94-c5bc893c520e branch from 8aeb7db to 6ab336e Compare May 16, 2025 06:40
@developer-guy
Copy link
Member

The build is failing with the following error:

INFO 🔗 ERROR in /home/build/src/cli/commands/fix/index.ts pkg=snyk-cli arch=arm64
INFO 🔗 ./src/cli/commands/fix/index.ts 2:25-36 pkg=snyk-cli arch=arm64
INFO 🔗 [tsl] ERROR in /home/build/src/cli/commands/fix/index.ts(2,26) pkg=snyk-cli arch=arm64
INFO 🔗       TS2307: Cannot find module '@snyk/fix' or its corresponding type declarations. pkg=snyk-cli arch=arm64
INFO 🔗  @ ./src/cli/commands/index.js 18:37-52 pkg=snyk-cli arch=arm64
INFO 🔗  @ ./src/cli/args.ts 87:16-37 pkg=snyk-cli arch=arm64
INFO 🔗  @ ./src/cli/main.ts 8:15-32 pkg=snyk-cli arch=arm64
INFO 🔗  @ ./src/cli/index.ts 13:56-73 pkg=snyk-cli arch=arm64

but I confirmed that build was succeeded with the previous version 1.1296.2 🫠

@developer-guy developer-guy self-assigned this May 16, 2025
@developer-guy
Copy link
Member

I reproduced the same problem on upstream as well:

$ make local-wolfi
$ apk add bash make go git npm nodejs-18 python3 make
$ git clone https://github.com/snyk/cli -b v1.1297.0
$ cd cli
$ make build
ERROR in /work/cli/src/cli/commands/fix/convert-legacy-tests-results-to-fix-entities.ts
./src/cli/commands/fix/convert-legacy-tests-results-to-fix-entities.ts 6:28-39
[tsl] ERROR in /work/cli/src/cli/commands/fix/convert-legacy-tests-results-to-fix-entities.ts(6,29)
      TS2307: Cannot find module '@snyk/fix' or its corresponding type declarations.
 @ ./src/cli/commands/fix/index.ts 8:55-112
 @ ./src/cli/commands/index.js 18:37-52
 @ ./src/cli/args.ts 87:16-37
 @ ./src/cli/main.ts 8:15-32
 @ ./src/cli/index.ts 13:56-73

ERROR in /work/cli/src/cli/commands/fix/index.ts
./src/cli/commands/fix/index.ts 2:25-36
[tsl] ERROR in /work/cli/src/cli/commands/fix/index.ts(2,26)
      TS2307: Cannot find module '@snyk/fix' or its corresponding type declarations.
 @ ./src/cli/commands/index.js 18:37-52
 @ ./src/cli/args.ts 87:16-37
 @ ./src/cli/main.ts 8:15-32
 @ ./src/cli/index.ts 13:56-73

Copy link
Contributor Author

octo-sts bot commented May 16, 2025

superseded by #53532

@octo-sts octo-sts bot closed this May 16, 2025
@octo-sts octo-sts bot deleted the wolfictl-299ce554-3a40-47b9-9a94-c5bc893c520e branch May 17, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/skip-comment Stop AI from commenting on PR auto-approver-bot/initial-checks-failed automated pr bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages. manual/review-needed request-version-update request for a newer version of a package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants