Installing Bun JS on WSL Ubuntu in Windows 10/11

Bun and Windows together!

Steps to installing Bun JS on Windows 10, or Windows 11, WSL with Ubuntu. Are you running into similar errors? Here's a quick fix for it.

Problem

After install bun in my WSL Ubuntu terminal I was getting these errors when trying to run it with the 'bun' command:

user@MyMachine:~$ bun
bun: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by bun)
bun: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by bun)
bun: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by bun)
bun: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.27' not found (required by bun)
bun: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by bun)
    

I was attempting to run Bun in Windows Subsystem for Linux with Ubuntu 16.04.3 LTS.

Fix

The missing references are from a newer version of the standard C libraries, available in a newer version of Ubuntu. Installing Ubuntu 22.04 LTS will resolve the error.

  1. Check your current version by typing the following command in the Ubuntu terminal:
    lsb_release -a
  2. Go to the Windows Start Menu and launch the Microsoft Store.
    microsoft store in start menu
  3. Download Ubuntu 22.04 LTS or later
    Ubuntu 22.04 LTS in microsoft store
  4. Once it's installed, start a terminal session in it, if it hasn't already launched itself.
  5. Install Bun with these terminal commands (from https://bun.sh)
    sudo apt install unzip
    curl https://bun.sh/install | bash
          
  6. After the following the onscreen instructions. You can now run Bun on WSL in Windows 10/11:
    bun

    user@MyMachine:~$ bun
    bun: a fast bundler, transpiler, JavaScript Runtime and package manager for web software.
    
    dev       ./a.ts ./b.jsx        Start a bun Dev Server
    bun       ./a.ts ./b.jsx        Bundle dependencies of input files into a .bun
    
    create    next ./app            Start a new project from a template (bun c)
    run       test                  Run JavaScript with bun, a package.json script, or a bin
    install                         Install dependencies for a package.json (bun i)
    add       contentlayer          Add a dependency to package.json (bun a)
    remove    backbone              Remove a dependency from package.json (bun rm)
    
    upgrade                         Get the latest version of bun
    completions                     Install shell completions for tab-completion
    discord                         Open bun's Discord server
    help                            Print this help menu
          

*Note

If you get the following error:
Command 'bun' not found
  
You may have missed the post-install instructions to add the below to your environment initialisation file (replace YOUR_USERNAME):
BUN_INSTALL="/home/<__YOUR_USERNAME__>/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
  

No comments:

Post a Comment