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 failing on installing Optional binary dependency: cpu-features #2666

Closed
a-x- opened this issue Apr 15, 2023 · 9 comments · Fixed by #7132
Closed

Bun failing on installing Optional binary dependency: cpu-features #2666

a-x- opened this issue Apr 15, 2023 · 9 comments · Fixed by #7132
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client

Comments

@a-x-
Copy link

a-x- commented Apr 15, 2023

What version of Bun is running?

0.5.8

What platform is your computer?

Darwin 22.2.0 arm64 arm

What steps can reproduce the bug?

bun add ssh2-promise

Checked 63 installs across 64 packages (no changes) [31.00ms]

  • @typescript-eslint/eslint-plugin@5.57.0
  • @typescript-eslint/parser@5.57.0
  • electron@23.2.2
  • electron-vite@1.0.21
  • eslint@8.36.0
  • eslint-config-prettier@8.8.0
  • eslint-plugin-react@7.32.2
  • prettier@2.8.7
  • typescript@4.9.5
  • vite@3.2.5
  • @electron-toolkit/preload@1.0.3
  • @emotion/react@11.10.6
  • @emotion/styled@11.10.6
  • @mui/icons-material@5.11.11
  • @mui/material@5.11.15
  • @mui/styles@5.11.13
  • react-router-dom@6.9.0
  • styled-components@5.3.9
  • ws@8.13.0
    • electron-builder version=23.6.0
    • loaded configuration file=/Users/mxtnr/xp/ee/skadi-app/electron-builder.yml
    • rebuilding native dependencies dependencies=cpu-features@0.0.6 platform=darwin arch=arm64
    ⨯ cannot execute cause=exit status 1 errorOut=error: script not found "rebuild"
    command=/Users/mxtnr/.bun/bin/bun rebuild cpu-features@0.0.6 workingDir=

172 packages installed [4.94s]
error: script "postinstall" exited with code 1 (SIGHUP)
error: script "dev" exited with code 1 (SIGHUP)

What is the expected behavior?

Install it (yarn does)
or just ignore this Optional dependency or add --no-optional flag like npm.
But it'll be super to skip only failing optional dependencies.
It's good idea to do it by default while suppressing error signal.

What do you see instead?

script not found "rebuild"

Additional information

ssh2@^1.10.0:
dependencies:
asn1 "^0.2.4"
bcrypt-pbkdf "^1.0.2"
optionalDependencies:
cpu-features "~0.0.4"
nan "^2.16.0"

@a-x- a-x- added the bug Something isn't working label Apr 15, 2023
@a-x- a-x- changed the title Bun cannot install binary dependency: cpu-features Bun failing on installing Optional binary dependency: cpu-features Apr 15, 2023
@Electroid Electroid added the bun install Something that relates to the npm-compatible client label Apr 16, 2023
@a-x-
Copy link
Author

a-x- commented May 13, 2023

I cannot use bun with my project...
Have any ideas?

@Electroid
Copy link
Contributor

We've fixed some issues with optional dependencies and bun install. If you are still running into this issue, please re-open this and we'll investigate.

@richbayliss
Copy link

richbayliss commented Nov 9, 2023

This is still an issue for me on bun@v1.0.11

What I did

$ bun build ./index.ts --target=node --outfile=bundle.js

error: Could not resolve: "../build/Release/cpufeatures.node"

const binding = require('../build/Release/cpufeatures.node');
                        ^
/usr/src/app/node_modules/cpu-features/lib/index.js:3:25 39

Dependencies

  • ssh2@1.14.0

@Electroid do you have any ideas why bun isn't building the native module after bun install , unlike npm which does?

@richbayliss
Copy link

scripts section of the package.json for cpu-features:

    "install": "node buildcheck.js > buildcheck.gypi && node-gyp rebuild",
    "test": "node test/test.js",
    "lint": "eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js lib test",
    "lint:fix": "npm run lint -- --fix"
  },

I guess the install script isn't being run 🤷🏻

@Hedronmx
Copy link

Hedronmx commented Mar 8, 2024

Whats the fix for this? I cant run my project because of this error

@Jarred-Sumner
Copy link
Collaborator

@Hedronmx are you running Bun v1.0.30? (or a recent version of bun)

@Hedronmx
Copy link

Hedronmx commented Mar 8, 2024

@Jarred-Sumner Yes! Just updated to bun 1.0.30 trying to fix the error

@Hedronmx
Copy link

@Jarred-Sumner upgraded to 1.0.33 and i still cant run my project. How can i fix it? Am I missing something? Sorry to be bothering you

@benallfree
Copy link

For a workaround, use bun patch :

patches/cpu-features@0.0.10.patch

diff --git a/node_modules/cpu-features/disabled.js b/disabled.js
new file mode 100644
index 0000000000000000000000000000000000000000..4d2d18c14a2f3334ce0227d2b9eabad3cb28e41c
--- /dev/null
+++ b/disabled.js
@@ -0,0 +1 @@
+throw new Error(`cpu-features not available on Bun`)
diff --git a/package.json b/package.json
index 6cc12c3c7703ea17995be61c5accc331e7e35014..da299bcca20a1a0654f6910c19d613ee776be478 100644
--- a/package.json
+++ b/package.json
@@ -3,10 +3,8 @@
   "version": "0.0.10",
   "author": "Brian White <mscdex@mscdex.net>",
   "description": "A simple binding to Google's cpu_features library for obtaining information about installed CPU(s)",
-  "main": "./lib/index",
+  "main": "./disabled.js",
   "dependencies": {
-    "buildcheck": "~0.0.6",
-    "nan": "^2.19.0"
   },
   "devDependencies": {
     "@mscdex/eslint-config": "^1.1.0",

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

Successfully merging a pull request may close this issue.

6 participants