Skip to content

Protect against spawn of CLI for wrong architecture #1317

Description

@danielkhan

Problem

The CLI is rarely used standalone. In most cases, it is executed via intermediates like the Sentry Webpack plugin.

When the CLI is installed via npm, it will run an install script that downloads a binary for the current architecture.

There are scenarios, when the architecture where the CLI eventually runs differs from the one npm install was executed from.

E.g.

  • A Dockerfile that will simply copy the local node_modules into the container
  • Any other deployment methods that will simply ship the bundle to the destination system including node_modules

This can lead to a rather obscure error when the binary is executed/spawned: #0 26.19 Sentry CLI Plugin: spawn Unknown system error -8.
I could reproduce this problem by running npm install @sentry/nextjs on an M1 Mac before running the application in Docker (Alpine).

The problem was reported by other users as well and we didn't come up with a solution proposal yet:

Quick fix

The problem can be solved by running

  • npm uninstall <sentry_module_that_installs_the_CLI_as_dep>
  • followed by npm install <sentry_module_that_installs_the_CLI_as_dep> as part of the deployment on the target system.

For a next.js application running in Docker, this would mean adding the following to the Dockerfile:

RUN npm uninstall -S @sentry/nextjs
RUN npm install -S @sentry/nextjs
# Further commands below, like:# RUN npm run build

This ensures that the right binary is downloaded for the target system.

Product improvement

Sentry should detect that the binary doesn't match the current architecture and provide an actionable error message to the user.
E.g.

WrongarchitecturedetectedwhiletryingtoexecutetheSentryCLI.Pleasemakesuretodoafreshnpmuninstall/installstepfor @sentrymodulesonthetargetsystem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions