Skip to content

Instantly share code, notes, and snippets.

@Samk13
Last active September 24, 2025 09:28
Show Gist options
  • Save Samk13/6fe053f6aea21727a8fb6ab7cb92709b to your computer and use it in GitHub Desktop.
Save Samk13/6fe053f6aea21727a8fb6ab7cb92709b to your computer and use it in GitHub Desktop.

Fix "Cairo not found" on macOS M ships even after installing with Homebrew

If you've installed Cairo via Homebrew (brew install cairo) but your scripts still can't find it, you may need to create symlinks in /usr/local/lib. This is because /usr/local/lib is always searched by macOS and is not blocked by SIP (System Integrity Protection).

Steps

  1. Create the directory if it doesn't exist:

    sudo mkdir -p /usr/local/lib
  2. Navigate to /usr/local/lib:

    cd /usr/local/lib
  3. Create symlinks to the Homebrew-installed Cairo library:

    sudo ln -sf /opt/homebrew/lib/libcairo.2.dylib libcairo.2.dylib
    sudo ln -sf /opt/homebrew/lib/libcairo.2.dylib libcairo.dylib
    sudo ln -sf /opt/homebrew/lib/libcairo.2.dylib libcairo.so.2
    sudo ln -sf /opt/homebrew/lib/libcairo.2.dylib libcairo-2.dylib

Why?

Some software expects Cairo libraries in /usr/local/lib. Homebrew installs them in /opt/homebrew/lib on Apple Silicon Macs, so symlinking resolves the issue.

Optional

Add these lines to your .zshenv to help your system locate the libraries:

export DYLD_FALLBACK_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_FALLBACK_LIBRARY_PATH"
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
export BREW_LIB='/opt/homebrew/lib'
export DYLD_LIBRARY_PATH=$BREW_LIB:$DYLD_LIBRARY_PATH

On solution that is not yet tested but could work is to place brew first in the PATH add this to the end of your zshrc

export PATH="/opt/homebrew/bin:$PATH"

other link:

https://jonathansoma.com/everything/blog/2022/solution-to-no-library-called-cairo-2-was-found-error/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment