Working on a system without root privilege is challenging when you need to install utilities. Homebrew is a popular rootless package manager widely used on macOS and Linux. However, installing Homebrew typically requires temporary root access to write to /home/linuxbrew.
While you can install to any other writable directory, this approach is unsupported and prevents access to pre-built binaries ("bottles")—meaning almost everything must be compiled from source, which is slow and tedious. This guide provides a workaround using PRoot to "fake" a writable /home/linuxbrew directory for your user, allowing Homebrew to function seamlessly without root access.
Find the latest PRoot binary from Gitlab - PRoot
Locate URL to the binary in Build > Jobs > Stage=dist, for example: https://gitlab.com/proot/proot/-/jobs/2370229665/artifacts/download?file_type=archive
# download PRoot artifacts
curl -L -o artifacts.zip <url>
# extract binary from zip file
unzip artifacts.zip
# install PRoot to ~/.local/bin directory
chmod +x dist/proot && mkdir -p ~/.local/bin && mv dist/proot ~/.local/bin/
# test PRoot is working
~/.local/bin/proot --versionShould be greeted with:
_____ _____ ___
| __ \ __ \_____ _____| |_
| __/ / _ \/ _ \ _|
|__| |__|__\_____/\_____/\____| v5.3.1-99a84175
built-in accelerators: process_vm = yes, seccomp_filter = yes
Visit https://proot-me.github.io for help, bug reports, suggestions, patches, ...
Copyright (C) 2022 PRoot Developers, licensed under GPL v2 or later.
# Create a installation directory that will be mapped to /home/linuxbrew
mkdir -p ~/linuxbrew
# Enter PRoot environment with ~/linuxbrew bind-mounted to /home/linuxbrew
# The -b flag creates a bind mount that maps directories
~/.local/bin/proot -b ~/linuxbrew:/home/linuxbrew bash
# You are now inside the PRoot environment where /home/linuxbrew appears writable
# Check the mapped directory, you should see the directory owned by your user and group
ls -al /home/linuxbrew
# Install Homebrew with the official script, Ignore sudo complains in the output
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Test Homebrew after installation
brew doctorAfter installation completes successfully, you can exit PRoot and continue with the automation setup below. brew will work seamlessly once you enable auto-loading in your shell.
For the PRoot environment to automatically load when the shell start, modify your .bashrc or .zshrc
#.zshrc
# Enter PRoot with Homebrew mapping
# --no-global-rcs prevent the spawned zsh from loading the profile again, use this flag carefully
if [[ $- == *i* ]] && [ ! -d "/home/linuxbrew" ]; then
PROOT_BIN="$HOME/.local/bin/proot"
LINUXBREW_DIR="$HOME/linuxbrew"
if [ -x "$PROOT_BIN" ] && [ -d "$LINUXBREW_DIR" ]; then
exec "$PROOT_BIN" -b "$LINUXBREW_DIR":/home/linuxbrew zsh --no-global-rcs
fi
fi
# Load Homebrew if inside PRoot
if [ -d "/home/linuxbrew" ] && [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fiWhen using Homebrew inside PRoot, pre-built binaries ("bottles") may not be available for all packages. This means some installations will need to be compiled from source, which can take significantly longer than standard Homebrew installations. For critical tools where build time matters, consider this factor in your workflow planning.