oven-sh / bun

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

Illegal instruction (core dumped) during installation #181

Closed WhoAteDaCake closed 1 year ago

WhoAteDaCake commented 2 years ago

Hi, I tried to run curl -fsSL https://bun.sh/install | bash command on my machine, which crashed with

######################################################################## 100.0%
Bun was installed successfully to /home/punch/.bun/bin/bun
bash: line 110: 78521 Illegal instruction     (core dumped) IS_BUN_AUTO_UPDATE="true" $exe completions > /dev/null 2>&1
Run 'bun --help' to get started

Linux: 5.17.0-051700-generic System:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy

Is there a way I could provide more information?

WhoAteDaCake commented 2 years ago

bun --help crashes the same way

Jarred-Sumner commented 2 years ago

This is most likely due to missing AVX2 instruction support.

Can you run this and tell me if it prints anything?

grep avx2 /proc/cpuinfo
WhoAteDaCake commented 2 years ago

I think you're right, I had similar problem with tensorflow as well.

grep avx2 /proc/cpuinfo

Returned nothing. Is there any workaround for this? Like if I build manually and pass a certain flag.

deijjji303 commented 2 years ago

Just a workaround: You can use the Intel-SDE to emulate avx2 capabilities, or at least that's what I'm currently doing. It is emulation so you might not be allowed to care about performance. Install intel-sde (I use arch btw and there it's in the AUR) and then do a cheeky sde -- bun --help At least the help page works with this for me personally and I'll play around with it a little to check if it 'just works'. Hope so anyways.

peeeuzin commented 2 years ago

Just a workaround: You can use the Intel-SDE to emulate avx2 capabilities, or at least that's what I'm currently doing. It is emulation so you might not be allowed to care about performance. Install intel-sde (I use arch btw and there it's in the AUR) and then do a cheeky sde -- bun --help At least the help page works with this for me personally and I'll play around with it a little to check if it 'just works'. Hope so anyways.

Screenshot_20220706_173953

it seems that doesn't work for me :(

deijjji303 commented 2 years ago

I'm new to the whole sde thing, just stumbled over it like half an hour ago, but what happens if you fiddle around with the -chip-check options? What happens if you try stuff like -chip-check-disable or -chip-check-exe-only? Just saw it in the -help-long so don't expect anything, I'm really no expert.

peeeuzin commented 2 years ago

Using -chip-check-disable works for me, maybe axv2 is able only on newer intel processor? idk about AXV2

Guztaver commented 2 years ago

Worked perfectly well for me! Now i can use bun. Thanks @deijjji303 and @pedrinfx!

Just a workaround: You can use the Intel-SDE to emulate avx2 capabilities, or at least that's what I'm currently doing. It is emulation so you might not be allowed to care about performance. Install intel-sde (I use arch btw and there it's in the AUR) and then do a cheeky sde -- bun --help At least the help page works with this for me personally and I'll play around with it a little to check if it 'just works'. Hope so anyways.

Using -chip-check-disable works for me, maybe axv2 is able only on newer intel processor? idk about AXV2

renhiyama commented 2 years ago

<path/to/sde/installation>/sde64 -chip-check-disable -- bun works perfectly!

For users who dont want to write such long line, they can make an alias and add it to your .bashrc or .zshrc ;)

alias sde='~/sde-external-9.7.0-2022-05-09-lin/sde64'
alias bun='sde -chip-check-disable -- bun'

and after restarting your shell, run bun and it just works perfectly, just like you have no problems in the first place :)

You can download the sde by running these lines btw:

 wget https://downloadmirror.intel.com/732268/sde-external-9.7.0-2022-05-09-lin.tar.xz
tar -xf sde-external-9.7.0-2022-05-09-lin.tar.xz

run the above in ur home folder, or edit the alias urself to keep the paths updated ;)

renhiyama commented 2 years ago

Btw, isnt bun's startup time a lot slower than node? Atleast when running with this sde... The http.ts file provided in example of bunjs takes like 10 secs to start up... Pretty sure nodejs would start it up in like 2-3 secs max... PS: Using wsl2 ubuntu, on Pentium cpu

deijjji303 commented 2 years ago

That is very true, yes. The reason for that is that in its current form, bun appears to leverage the avx2 instruction set to do very specific things way more efficiently. What we are doing here is emulating the 'avx2 part of the cpu' (idk maybe even the whole cpu) in order to get it to run. Does it provide us with buns speed benefit? I guess no, really not. Does it allow us to play around with buns all inclusive toolset? Yea. The SDE way isn't for people who want to use bun because it's faster, but for those who just want so have some way of playing around with it. Would be very nice if at some point there would be a non-avx2 version of bun, that would still be faster than node etc. to some degree, so I really hope that for unsupported CPU's this is not the permanent way to run things

faresbakhit commented 2 years ago

I think a little note about this in the readme would be good for newcomers until this issue is resolved

deijjji303 commented 1 year ago

Also just for completeness: possible duplicate of #67

zekefeu commented 1 year ago

I've made a script to simplify and automate SDE's installation based on @renhiyama's solution, lmk if there's anything to fix.

$ curl https://gist.githubusercontent.com/fuka-g/afb29296db34d2451cdddcc14dbeef3c/raw/0c9e5d43910cf53b9bd82b358559bb8b75ebbfdc/bun-sde-fix-install_script.sh | bash

EDIT: Updated script, this one is up to date.

spidy0x0 commented 1 year ago

Script updated to fix architecture issues https://gist.github.com/spidyhackx/194108a0df2b4fc8df642f126edcc0e5