bun

Bun Not Found After Running Installation Script


I have ran the installation script by pasting this code:

$ curl https://bun.sh/install | bash

However, when I try to get the version of bun, it says it could not find it:

$ bun --version

Command 'bun' not found, did you mean:

  command 'ben' from deb ben (0.9.0ubuntu2)
  command 'bus' from deb atm-tools (1:2.5.1-4)
  command 'zun' from deb python3-zunclient (4.0.0-0ubuntu1)

Try: sudo apt install <deb name>

Solution

  • I had the same issue running on Windows 10 WSL2 Ubuntu-22.04 with Bun v0.1.5.

    The solution (and more detail just in case anyone needs it) below:

    The executable for bun is in the directory "/home/username/.bun". You need to add this to your $PATH so that this can be found when typing bun commands such as "bun --help".

    The bun setup process does not add this path so you need to do it yourself.

    Two ways to do this :

    (1) Manual method

    Type in the terminal:

    export BUN_INSTALL="/home/YOUR_USERNAME/.bun"
    export PATH="$BUN_INSTALL/bin:$PATH"
    

    Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).

    Note: This process will have to be REPEATED for every new shell you open.

    (2) Automatic method

    Edit the .bashrc file :

    nano ~/.bashrc 
    

    at the end of this file add

    BUN_INSTALL="/home/YOUR_USERNAME/.bun"
    PATH="$BUN_INSTALL/bin:$PATH"
    

    Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).

    (Remember to save your changes with Ctrl-O)

    Note: You will NEED TO OPEN A NEW SHELL for this to work OR type 'source ~/.bashrc' to use in the current terminal.

    You should now be able to run bun commands in any new shell.