oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.29k stars 2.77k forks source link

Error with `create vite` on M2 OSX. #7356

Closed take0ut closed 11 months ago

take0ut commented 11 months ago

What version of Bun is running?

1.0.11+f7f6233ea

What platform is your computer?

Darwin 21.6.0 x86_64 i386

What steps can reproduce the bug?

On my M2 Macbook Air, I get an error when trying to run a vite application created with bun create vite

➜ bun dev                  
$ vite
failed to load config from /Users/orenweingrod/Code/sfpc/birdwatching/vite.config.ts
error when starting dev server:
Error: 
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "@esbuild/darwin-arm64" package is present but this platform
needs the "@esbuild/darwin-x64" package instead. People often get into this
situation by installing esbuild with npm running inside of Rosetta 2 and then
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
2 is Apple's on-the-fly x86_64-to-arm64 translation service).

If you are installing with npm, you can try ensuring that both npm and node are
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
changing how you installed npm and/or node. For example, installing node with
the universal installer here should work: https://nodejs.org/en/download/. Or
you could consider using yarn instead of npm which has built-in support for
installing a package on multiple platforms simultaneously.

If you are installing with yarn, you can try listing both "arm64" and "x64"
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.

Steps to reproduce:

1) Create a new vite application using bun create vite 2) Select React and Typescript as options for vite application creation. 3) Run bun install in the newly created application directory 4) Run bun dev in the application directory—you should see the above error.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

This error also appears when creating a vite application with vanilla Typescript or Javascript (React does not appear to be related to the bug).

Electroid commented 11 months ago

Your computer is an M2, but it's reporting that it's an x64 machine. Is your shell running using Rosetta? If sysctl -n sysctl.proc_translated returns 1, then you are running in Rosetta.

take0ut commented 11 months ago

sysctl -n sysctl.proc_translated returns 1

Yup, this was the case! Interestingly enough, my main terminal is running on the correct architecture, but the terminal inside of VSCode is running under Rosetta.

Closing this issue, as this one is on me!