Homebrew can manage command-line packages inside a Linux distribution running under Windows Subsystem for Linux. Installing it in WSL gives Windows users the Linuxbrew package path and keeps brew operations inside the Linux filesystem instead of trying to run Homebrew directly from PowerShell.

The supported Linux and WSL installer uses the default /home/linuxbrew/.linuxbrew prefix. That prefix lets Homebrew use most precompiled packages and keeps later brew install operations from needing sudo after the initial setup.

Use a normal WSL 2 distribution shell, such as Ubuntu or Debian. Ubuntu and Debian WSL distributions use APT packages for the prerequisites; other WSL distributions need equivalent compiler, Git, curl, file, process, and sandbox tools before running the installer.

Steps to install Homebrew inside WSL:

  1. Check the WSL version for the target Linux distribution from PowerShell.
    PS> wsl.exe --list --verbose
      NAME      STATE           VERSION
    * Ubuntu    Running         2

    Homebrew recommends WSL 2. Convert an existing WSL 1 distribution before installing when this table shows VERSION 1.

  2. Open the target WSL distribution shell.
    PS> wsl.exe --distribution Ubuntu
  3. Refresh the APT package index inside WSL.
    $ sudo apt-get update
    Reading package lists... Done
  4. Install Homebrew's Linux prerequisites.
    $ sudo apt-get install build-essential procps curl file git bubblewrap ca-certificates
    Setting up build-essential (12.12ubuntu2.26.04.1) ...
    Setting up bubblewrap (0.11.1-1ubuntu0.1) ...
    Setting up curl (8.18.0-1ubuntu2.2) ...
    Setting up git (1:2.53.0-1ubuntu1) ...

    build-essential provides the compiler toolchain, curl downloads the installer, Git fetches Homebrew, and bubblewrap is part of current Homebrew on Linux dependency checks. Package versions differ by WSL distribution release.

  5. Run the official Homebrew installer inside the WSL shell.
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    ==> This script will install:
    /home/linuxbrew/.linuxbrew/bin/brew
    /home/linuxbrew/.linuxbrew/share/doc/homebrew
    /home/linuxbrew/.linuxbrew/share/man/man1/brew.1
    /home/linuxbrew/.linuxbrew/Homebrew
    ##### snipped #####
    ==> Installation successful!
    ==> Next steps:
    - Run these commands in your terminal to add Homebrew to your PATH:
        echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc
        eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"

    The installer explains the directories it will create and prompts before making changes during a normal interactive run.

  6. Load Homebrew into the current Bash session.
    $ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
  7. Add Homebrew to future Bash sessions.
    $ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc

    Use ~/.zshrc and brew shellenv zsh instead when the WSL distribution uses zsh as the interactive shell.
    Related: How to configure Homebrew shell environment

  8. Close and reopen the WSL shell.
  9. Confirm that the shell resolves the Homebrew command from the Linuxbrew prefix.
    $ command -v brew
    /home/linuxbrew/.linuxbrew/bin/brew
  10. Confirm the active Homebrew prefix.
    $ brew --prefix
    /home/linuxbrew/.linuxbrew
  11. Confirm that Homebrew runs from the reopened WSL shell.
    $ brew --version
    Homebrew 6.0.8

    The exact Homebrew version changes over time. The important checks are that command -v brew resolves under /home/linuxbrew/.linuxbrew/bin and brew --prefix prints /home/linuxbrew/.linuxbrew.