Skip to content
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

bun install / binary in wrong place #2998

Closed
samopus1io opened this issue May 22, 2023 · 9 comments
Closed

bun install / binary in wrong place #2998

samopus1io opened this issue May 22, 2023 · 9 comments
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client

Comments

@samopus1io
Copy link

What version of Bun is running?

0.6.2

What platform is your computer?

Darwin 22.4.0 arm64 arm

What steps can reproduce the bug?

  • yarn init
  • yarn add @sentry/cli

notice sentry-cli below.

❯ ls -la node_modules/@sentry/cli
total 52296
drwxr-xr-x@ 11 samlll42  wheel       352 May 22 09:58 .
drwxr-xr-x@  3 samlll42  wheel        96 May 22 09:57 ..
-rw-r--r--@  1 samlll42  wheel      1528 May 22 09:57 LICENSE
-rw-r--r--@  1 samlll42  wheel      5309 May 22 09:57 README.md
drwxr-xr-x@  3 samlll42  wheel        96 May 22 09:57 bin
-rw-r--r--@  1 samlll42  wheel       814 May 22 09:57 checksums.txt
drwxr-xr-x@  7 samlll42  wheel       224 May 22 09:57 js
drwxr-xr-x@  3 samlll42  wheel        96 May 22 09:57 node_modules
-rw-r--r--@  1 samlll42  wheel      1633 May 22 09:57 package.json
drwxr-xr-x@  7 samlll42  wheel       224 May 22 09:57 scripts
-rwxr-xr-x@  1 samlll42  wheel  26751672 May 22 09:58 sentry-cli

with Bun the sentry-cli binary is not there

❯ bun install @sentry/cli --yarn
bun add v0.6.2 (8d90d795)

 installed @sentry/[email protected] with binaries:
  - sentry-cli


 13 packages installed [332.00ms]
❯ ls -la node_modules/@sentry/cli
total 40
drwxr-xr-x@ 9 samlll42  wheel   288 May 22 09:58 .
drwxr-xr-x@ 3 samlll42  wheel    96 May 22 09:58 ..
-rw-r--r--@ 1 samlll42  wheel  1528 May 22 09:58 LICENSE
-rw-r--r--@ 1 samlll42  wheel  5309 May 22 09:58 README.md
drwxr-xr-x@ 3 samlll42  wheel    96 May 22 09:58 bin
-rw-r--r--@ 1 samlll42  wheel   814 May 22 09:58 checksums.txt
drwxr-xr-x@ 7 samlll42  wheel   224 May 22 09:58 js
-rw-r--r--@ 1 samlll42  wheel  1633 May 22 09:58 package.json
drwxr-xr-x@ 7 samlll42  wheel   224 May 22 09:58 scripts

What is the expected behavior?

It looks like bun install is not handling certain part of the package install correctly or am I missing something?

What do you see instead?

No response

Additional information

No response

@samopus1io samopus1io added the bug Something isn't working label May 22, 2023
@Electroid Electroid added the bun install Something that relates to the npm-compatible client label May 22, 2023
@canopus1io
Copy link

image
I have found that after running this install script, sentry-cli is in the root of the node_modules

yarn must be executing this script as part of the install process

@muan
Copy link

muan commented Aug 1, 2023

I just ran into the same problem with sqlite3 package which also has an install script that was not run when I add the package with bun add but does when I add it with yarn.

@crishoj
Copy link

crishoj commented Aug 25, 2023

I just ran into the same problem with sqlite3 package which also has an install script that was not run when I add the package with bun add but does when I add it with yarn.

For anyone in the same situation, to invoke the missing install script for sqlite3 manually, do:

cd node_modules/sqlite3
npx node-pre-gyp install --fallback-to-build

@zachbryant
Copy link

For packages that don't have an install script, this is still an issue. On a fresh install with just-scripts, I expected to see the path node_modules/just-scripts/bin/just-scripts.js, however all I see are a trail of node_modules folders with no binaries.

@HappyGick
Copy link

Ran into this problem when using the ssh2 package. It couldn't find a binary dependency and thus didn't run.

@byCedric
Copy link

byCedric commented Sep 26, 2023

I don't think this is an issue with Bun, it's caused by Sentry's own CLI wrapping script. The Sentry CLI is written in Rust, and therefore is a bit "wacky" regarding npm installs. Basically, they have:

And, due to Bun not executing lifecycle scripts, this Rust binary install script is never called. This is "due to security risks", which makes sense.

Can you add trustedDependencies this to your package.json @samopus1io, delete lock file (bun.lockb) and local modules (node_modules), and install again through bun install? E.g. like:

{
  "name": "my-app",
  "version": "1.0.0",
  ...
  "trustedDependencies": ["@sentry/cli"],
  ...
}

Then run:

$ rm -rf node_modules bun.lockb
$ bun install

No idea why Sentry just doesn't ship their Rust binary within the npm package, and instead, rely on remotely downloading an executable binary 🙈

@juanmagalhaes
Copy link

I don't think this is an issue with Bun, it's caused by Sentry's own CLI wrapping script. The Sentry CLI is written in Rust, and therefore is a bit "wacky" regarding npm installs. Basically, they have:

And, due to Bun not executing lifecycle scripts, this Rust binary install script is never called. This is "due to security risks", which makes sense.

Can you add trustedDependencies this to your package.json @samopus1io, delete lock file (bun.lockb) and local modules (node_modules), and install again through bun install? E.g. like:

{
  "name": "my-app",
  "version": "1.0.0",
  ...
  "trustedDependencies": ["@sentry/cli"],
  ...
}

Then run:

$ rm -rf node_modules bun.lockb
$ bun install

No idea why Sentry just doesn't ship their Rust binary within the npm package, and instead, rely on remotely downloading an executable binary 🙈

Had this same issue and this fix worked for me! Thank you @byCedric!!!

@lksnmnn
Copy link

lksnmnn commented Oct 16, 2023

Hey, I am having the same issue with @sentry/nextjs. However, adding both this and the cli package as trustedDependencies does work. I even cleared the global bun cache to no avail.

@dylan-conway
Copy link
Member

Closing as complete. This was fixed when support for lifecycle scripts was added to bun install in Bun v1.0.17.

Packages that aren't in the default trusted list will need to be added to "trustedDependencies" in package.json for their scripts to run on install. You can edit manually or use bun add <package> --trust. If the package is already installed, bun pm trust can be used to run scripts and add to package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests