Skip to main content
ertius.org

ansible, m1, libssh

For some reason I haven't been able to track down, the way that uv and ansible try to build libssh doesn't work by default with Homebrew on a Mac M1.

❯ time uv run --python python3.11 ansible-playbook -v site.yaml --ask-vault-pass -l somehostname.somedomain.net
Using CPython 3.11.12 interpreter at: /opt/homebrew/opt/python@3.11/bin/python3.11
Removed virtual environment at: .venv
Creating virtual environment at: .venv
  × Failed to build `ansible-pylibssh==1.2.2`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `pep517_backend.hooks.build_wheel` failed (exit status: 1)

      [stdout]
      [1/1] Cythonizing /private/var/folders/3h/5gk_xh696gs1hv86j9tdy6wh0000gn/T/.tmp-ansible-pylibssh-pep517-m8al31hk/src/src/pylibsshext/_libssh_version.pyx

      [stderr]
      /private/var/folders/3h/5gk_xh696gs1hv86j9tdy6wh0000gn/T/.tmp-ansible-pylibssh-pep517-m8al31hk/src/src/pylibsshext/_libssh_version.c:1236:10: fatal error: 'libssh/libssh.h' file
      not found
       1236 | #include "libssh/libssh.h"
            |          ^~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1

      hint: This error likely indicates that you need to install a library that provides "libssh/libssh.h" for `ansible-pylibssh@1.2.2`
  help: `ansible-pylibssh` (v1.2.2) was included because `myansible` (v0.0.1) depends on `ansible-pylibssh`
user=0.85s system=0.41s cpu=88% total=1.426

The workaround, which I forgot from last time, is:

export C_INCLUDE_PATH=/opt/homebrew/include:$C_INCLUDE_PATH
export LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH