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

Broken install binary on macOS #462

Closed
mplesec opened this issue Oct 16, 2020 · 25 comments
Closed

Broken install binary on macOS #462

mplesec opened this issue Oct 16, 2020 · 25 comments

Comments

@mplesec
Copy link

mplesec commented Oct 16, 2020

I'm guessing this is a new bug since this project supports macOS (didn't test with older versions).

Running yarn add -D esbuild installs this package as expected, however this is the installed binary:

% cat node_modules/esbuild/bin/esbuild
#!/usr/bin/env node
throw new Error(`esbuild: Failed to install correctly`);

System is macOS 10.15.7 (19H2), yarn v1.22.4, node v12.16.1

@nettybun
Copy link

Have you tried stepping through the installation commands relevant to Mac? https://www.github.com/evanw/esbuild/tree/master/lib%2Finstall.ts

There's a Library/Caches directory involved which might be a permission issue... Can you show the relevant npm logs

@mplesec
Copy link
Author

mplesec commented Oct 16, 2020

There's no error when installing it, this is the output:

 % yarn add -D esbuild
yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
warning Ignored scripts due to flag.
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ esbuild@0.7.15
info All dependencies
└─ esbuild@0.7.15
✨  Done in 1.64s.

The yarn-error.log output is:

Arguments:
  /Users/me/.nvm/versions/node/v12.18.3/bin/node /usr/local/Cellar/yarn/1.22.4/libexec/bin/yarn.js init

PATH:
  /Users/me/.nvm/versions/node/v12.18.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin/python:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/local/lib/python3.7/site-packages:/Users/me/bin:/Users/me/.cargo/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/me/Workspace/techops/bin:/Users/me/Library/Python/3.7/bin:saml2aws:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/me/.go/bin:/usr/local/opt/go/libexec/bin

Yarn version:
  1.22.4

Node version:
  12.18.3

Platform:
  darwin x64

Trace:
  Error: canceled
      at Interface.<anonymous> (/usr/local/Cellar/yarn/1.22.4/libexec/lib/cli.js:137008:13)
      at Interface.emit (events.js:315:20)
      at Interface._ttyWrite (readline.js:868:16)
      at ReadStream.onkeypress (readline.js:205:10)
      at ReadStream.emit (events.js:315:20)
      at emitKeys (internal/readline/utils.js:335:14)
      at emitKeys.next (<anonymous>)
      at ReadStream.onData (readline.js:1137:36)
      at ReadStream.emit (events.js:315:20)
      at addChunk (_stream_readable.js:295:12)

npm manifest:
  No manifest

yarn manifest:
  No manifest

Lockfile:
  No lockfile

However, now saw the warning and the problem was with my npm config. I had ignore-scripts set to true.

Running npm config set ignore-scripts false fixes the issue. 🎉 Thank you!

@nettybun
Copy link

Interesting, I wonder if esbuild's bin executable could just run install.ts instead of displaying an error about failing to install. Might be more streamlined for anyone else with ignore-scripts enabled.

@evanw
Copy link
Owner

evanw commented Oct 16, 2020

Thanks for the heads up about this.

Interesting, I wonder if esbuild's bin executable could just run install.ts instead of displaying an error about failing to install. Might be more streamlined for anyone else with ignore-scripts enabled.

I could see that working fine, but I could also see that causing other issues. I'm going to try making the error message mention ignore-scripts first since that seems less risky.

@evanw evanw closed this as completed in efb3350 Oct 16, 2020
@quantuminformation
Copy link

It stopped working with vite

/Users/nikos/WebstormProjects/mentorcv/node_modules/esbuild/bin/esbuild:2
throw new Error(`esbuild: Failed to install correctly
^

Error: esbuild: Failed to install correctly

Make sure you don't have "ignore-scripts" set to true. You can check this with
"npm config get ignore-scripts". If that returns true you can reset it back to
false using "npm config set ignore-scripts false" and then reinstall esbuild.```

@evanw
Copy link
Owner

evanw commented Nov 24, 2020

What does npm config get ignore-scripts say? What package manager are you using? Any error output from when the package was installed?

@quantuminformation
Copy link

image

@quantuminformation
Copy link

@heyheyhello nice random downvote

@nettybun
Copy link

You're not helping debug the issue. If you don't want to respond to questions or help find a solution then you can leave. It's not complicated ❤️

@quantuminformation
Copy link

quantuminformation commented Nov 25, 2020

What are you talking about, I responded to a direct question. Your team members must loving working with you.

@nettybun
Copy link

Ok let's walk you through it 🙃

You've ran an npm command but are you using that as your package manager when you encountered the error? (This question was already asked). There have been specific issues with Yarn regarding the esbuild executable, so this is important to know.

When you run the installation from your package manager, do you see output related to the post-install script that installs esbuild? (This question was already asked). Other people have been helpful in providing the output and debug information; you could share that too :)

Some other questions: Is this reproducable? or a one time thing that was fixed after redoing the install. Have you tried to run the installation manually? Also, as a member of the Vite community, have you heard of other people having the issue?

Thanks ☀️

@evanw
Copy link
Owner

evanw commented Nov 25, 2020

Your team members must loving working with you.

That was uncalled for. Please keep the discussion to the issue you're having and free from personal remarks like this.

@quantuminformation
Copy link

quantuminformation commented Nov 25, 2020

Ok, and it's ok to tell random folk in discord If you don't want to respond to questions or help find a solution then you can leave

As you can tell hehhey has 10x more time in the day to write then I do

@eranimo
Copy link

eranimo commented Jan 16, 2021

I'm getting the same problem and ignore-scripts is also false.

Version: 0.8.32
MacOS 10.14.6
using npm 7.3.0

@eranimo
Copy link

eranimo commented Jan 16, 2021

Oh interestingly, the problem goes away when not using npm v7.

@eikeon
Copy link

eikeon commented Jan 16, 2021

I'm getting the same problem and ignore-scripts is also false.

Version: 0.8.32
MacOS 10.14.6
using npm 7.3.0

I can only get it working after first installing an older version. I think npm i --verbose esbuild@0.7.0 installed a working binary for me. After which I can install version 0.8.32... even after rm -rf node_modules -- not sure what's being cached where re: side effect of installing an older version first.

@Anoesj
Copy link

Anoesj commented Jan 26, 2021

Maybe this info is useless, but just in case.

When using pnpm to manage node modules, installing rollup-plugin-esbuild also installs esbuild (peer dep) automatically, so I guess pnpm installs peer deps automatically. In this particular case however, esbuild's postinstall script did run when running pnpm install locally, but it did not run on our production server, even though the esbuild package is installed. Because the postinstall script did not run on our production server, I also got the Error: esbuild: Failed to install correctly error there.

I've asked the maintainer of pnpm if this is the correct behavior of pnpm. I'm not sure if npm shows the same behavior. For now, I fixed the issue by manually requiring esbuild as a devDependency, instead of relying on automatically installed peer deps.

@Otto-J
Copy link

Otto-J commented Feb 2, 2021

same problem using npm in Mac

it can be sloved by:

node node_modules/esbuild/install.js

before npm run dev

@evanw
Copy link
Owner

evanw commented Feb 3, 2021

I'm getting the same problem and ignore-scripts is also false.

Oh interestingly, the problem goes away when not using npm v7.

I just experienced this as well. After a lot of debugging it turns out it was a bug in npm itself, which is now tracked here: npm/cli#2606. If you're having the same issue that I had, regenerating your package-lock.json file will fix it. The problem is that npm v7 can corrupt existing package-lock.json files from npm v6. I will update esbuild's error message in the next release to describe this problem and how to work around it.

@halfkai
Copy link

halfkai commented Feb 4, 2021

got same problem here. already set ignore-scripts to false, still macOS failed to install esbuild when using npm @7.5.2, succeed after change npm to yarn.

@IanBellomy
Copy link

May have hit the same issue with npm but upgraded to 7.5.4 and things look good.

@oldlie
Copy link

oldlie commented Feb 21, 2021

same problem using npm in Mac

it can be sloved by:

node node_modules/esbuild/install.js

before npm run dev

Problem fixed, thank you :)

@vphilot
Copy link

vphilot commented Apr 7, 2021

same problem using npm in Mac

it can be sloved by:

node node_modules/esbuild/install.js

before npm run dev

this worked like a charm! thank you!

@yangyuji
Copy link

yangyuji commented Feb 9, 2023

I'm getting the same problem and ignore-scripts is also false.

Version: 0.16.17
MacOS 10.12.6
using npm 9.4.2

Running: node node_modules/esbuild/install.js
It stopped working with vite:
...node_modules/esbuild/install.js:117
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
^

Error: The "esbuild" package cannot be installed because macOS 10.12.6 is too outdated.

The Go compiler (which esbuild relies on) no longer supports macOS 10.12.6,
which means the "esbuild" binary executable can't be run. You can either:

  • Update your version of macOS to one that the Go compiler supports
  • Use the "esbuild-wasm" package instead of the "esbuild" package
  • Build esbuild yourself using an older version of the Go compiler

@yangerxia
Copy link

I'm getting the same problem and ignore-scripts is also false.

Version: 0.16.17
MacOS 10.12.6
using npm 9.4.2

Running: node node_modules/esbuild/install.js
It stopped working with vite:
...node_modules/esbuild/install.js:117
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
^

Error: The "esbuild" package cannot be installed because macOS 10.12.6 is too outdated.

The Go compiler (which esbuild relies on) no longer supports macOS 10.12.6,
which means the "esbuild" binary executable can't be run. You can either:

Update your version of macOS to one that the Go compiler supports
Use the "esbuild-wasm" package instead of the "esbuild" package
Build esbuild yourself using an older version of the Go compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests