sentry-javascript: Vercel + Nextjs cannot find Sentry CLI binary

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.60.1

Framework Version

Next 13.4.12 and react 18.2.0

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Setup a simple monorepo with Turborepo
  2. Copy over this nextjs app https://github.com/vercel/next.js/tree/canary/examples/with-sentry
  3. Upload to vercel

Expected Result

Source maps are uploaded properly.

Actual Result

The sentry upload reports the following error: error - Sentry CLI binary not found. Source maps will not be uploaded.

Screenshot 2023-07-26 at 8 21 41 PM

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 9
  • Comments: 40 (14 by maintainers)

Most upvoted comments

Yarn berry pnp solution

packageExtensions:
  '@sentry/utils@*':
    dependencies:
      '@sentry/webpack-plugin': '1.20.0'

Write this in yarnrc.yaml

@sentry/nextjs uses loadModule() to import @sentry/webpack-plugin. but, loadMoudle() is in @sentry/utils and @sentry/utils has not @sentry/webpack-plugin dependency.
yarn berry pnp points out that this is ambiguous dependency.

(sorry bad english)

@bastiankistner Thank you for your concern. Trust me this is being looked at. I am also extremely annoyed by the persistence and frequency of this bug (because I have to keep explaining) and I keep bugging my manager to be able to allocate time to fix this.

@webjay Since you’re using bun you need to add @sentry/cli as a trusted dependency: https://bun.sh/guides/install/trusted

I have a similar problem to @webjay but I dont have the webpack error message.

I’m switching an existing React project (custom webpack build) that used Sentry over to a next.js project (using default Next.js configs). I am an existing Sentry customer, and have done a number of integrations over the years, including with Nextjs.

I used the @sentry/wizard npx tool to set up my integration. I was able to see the example API error in the sentry UI.

When I start up my app, I get the “Can not find sentry CLI binary” message.

~I will try downgrading Next.js since i’m currently running the latest 14.0.1 and perhaps that’s causing issues.~ Edit: I tried downgrading to the most recent Next 13 build, and the error was the same. image

My build works with "next": "12.3.4", "@sentry/nextjs": "7.75.1"

But not with "next": "14.0.1", "@sentry/nextjs": "7.77.0":

import { withSentryConfig } from '@sentry/nextjs';

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  eslint: {
    dirs: ['.'],
  },
  sentry: {
    hideSourceMaps: true,
    autoInstrumentServerFunctions: true,
  },
  // experimental: { webpackBuildWorker: true },
};

const sentryWebpackPluginOptions = {
  silent: true,
};

export default withSentryConfig(nextConfig, sentryWebpackPluginOptions);

Thank you very much @iforst!! It seems that updating my Next.js SDK and removing @Sentry/cli solved my problem!

@iforst Yes, I tried that too. Sorry I forgot to mention it. However, I’ve run it again just in case, but I get the same error 😦

@saguilarolmo Hm that sucks. Just dumping a few things, please ignore if you already tried them:

  • Delete any .sentryclirc or sentry.properties files and redeploy without cache
  • Upgrade Next.js SDK to latest
  • Remove the direct dependency to @sentry/cli
  • Triple double check whether your package manager is running post-install scripts

Thinking about adding a step to just download the binary during the build…

Do you mean that if it doesn’t find sentry-cli at build time, it downloads the sentry-cli binary from sentry’s internal code?

Yep. So when you build your app, in the case you would upload source maps, the SDK just downloads the binary if it is not there and then continues the build.

@baptisteArno This workaround worked for us. Add a manual run of the cli install script as the first part of your buildCommand:

node /vercel/path0/node_modules/.pnpm/@sentry+cli@*/node_modules/@sentry/cli/scripts/install.js && \
...rest of your build command

Awesome, that works 🙌

@baptisteArno This workaround worked for us. Add a manual run of the cli install script as the first part of your buildCommand:

node /vercel/path0/node_modules/.pnpm/@sentry+cli@*/node_modules/@sentry/cli/scripts/install.js && \
...rest of your build command

Please check that your postinstall scripts are running when installing your dependencies

For any future googlers, this was our issue – we had been using yarn install --immutable --mode=skip-build in CI, and the skip-build mode prevented post-install scripts from running, which prevented the sentry-cli binary from being found.

@Xhale1 Please check if the sentry-cli binary is located in @sentry/cli/bin.

In any case. Vercel caches builds and dependecies. Can you try rerunning a build without cache? There’s a checkbox in Vercel for that.