Edit on Github

Installing ROS 2 on macOS

This page explains how to install ROS 2 on macOS from a pre-built binary package.

Note

The pre-built binary does not include all ROS 2 packages. All packages in the ROS base variant are included, and only a subset of packages in the ROS desktop variant are included. The exact list of packages are described by the repositories listed in this ros2.repos file.

System requirements

We support macOS Mojave (10.14).

Installing prerequisites

You need the following things installed before installing ROS 2.

  • brew (needed to install more stuff; you probably already have this):

    • Follow installation instructions at http://brew.sh/

    • Optional: Check that brew is happy with your system configuration by running:

        brew doctor
      
      
      Fix any problems that it identifies.
      
  • Use brew to install more stuff:

    brew install python@3.8
    # Unlink in case you have python@3.7 installed already
    brew unlink python
    # Make the python command be Python 3.8
    brew link --force python@3.8
    
    # install asio and tinyxml2 for Fast-RTPS
    brew install asio tinyxml2
    
    # install dependencies for robot state publisher
    brew install tinyxml eigen pcre poco
    
    # OpenCV isn't a dependency of ROS 2, but it is used by some demos.
    brew install opencv
    
    # install OpenSSL for DDS-Security
    brew install openssl
    # if you are using ZSH, then replace '.bashrc' with '.zshrc'
    echo "export OPENSSL_ROOT_DIR=$(brew --prefix openssl)" >> ~/.bashrc
    
    # install Qt for RViz
    brew install qt freetype assimp
    
    # install console_bridge for rosbag2
    brew install console_bridge
    
    # install dependencies for rcl_logging_log4cxx
    brew install log4cxx spdlog
    
    # install CUnit for Cyclone DDS
    brew install cunit
    
  • Install rqt dependencies

    brew install sip pyqt5

    Fix some path names when looking for sip stuff during install (see ROS 1 wiki):

    ln -s /usr/local/share/sip/Qt5 /usr/local/share/sip/PyQt5

    brew install graphviz

    python3 -m pip install pygraphviz pydot

    Note

    You may run into an issue installing pygraphviz, “error: Error locating graphviz”. Try the following install command instead:

    python3 -m pip install --install-option="--include-path=/usr/local/include/" --install-option="--library-path=/usr/local/lib/" pygraphviz
    
  • Install SROS2 dependencies

    python3 -m pip install lxml

  • Install additional runtime dependencies for command-line tools:

    python3 -m pip install catkin_pkg empy ifcfg lark-parser lxml netifaces numpy pyparsing pyyaml setuptools argcomplete
    

Disable System Integrity Protection (SIP)

macOS/OS X versions >=10.11 have System Integrity Protection enabled by default. So that SIP doesn’t prevent processes from inheriting dynamic linker environment variables, such as DYLD_LIBRARY_PATH, you’ll need to disable it following these instructions.

Downloading ROS 2

  • Go to the releases page: https://github.com/ros2/ros2/releases

  • Download the latest package for macOS; let’s assume that it ends up at ~/Downloads/ros2-release-distro-date-macos-amd64.tar.bz2.

    • Note: there may be more than one binary download option which might cause the file name to differ.

  • Unpack it:

    mkdir -p ~/ros2_foxy
    cd ~/ros2_foxy
    tar xf ~/Downloads/ros2-release-distro-date-macos-amd64.tar.bz2
    

Install additional DDS implementations (optional)

If you would like to use another DDS or RTPS vendor besides the default, eProsima’s Fast RTPS, you can find instructions here.

Environment setup

Source the ROS 2 setup file:

. ~/ros2_foxy/ros2-osx/setup.bash

Try some examples

In one terminal, set up the ROS 2 environment as described above and then run a C++ talker:

ros2 run demo_nodes_cpp talker

In another terminal, set up the ROS 2 environment and then run a Python listener:

ros2 run demo_nodes_py listener

You should see the talker saying that it’s Publishing messages and the listener saying I heard those messages. This verifies both the C++ and Python APIs are working properly. Hooray!

See the tutorials and demos for other things to try.

Build your own packages

If you would like to build your own packages, refer to the tutorial "Using Colcon to build packages".

Troubleshooting

Troubleshooting techniques can be found here.

Uninstall

  1. If you installed your workspace with colcon as instructed above, “uninstalling” could be just a matter of opening a new terminal and not sourcing the workspace’s setup file. This way, your environment will behave as though there is no Foxy install on your system.

  2. If you’re also trying to free up space, you can delete the entire workspace directory with:

    rm -rf ~/ros2_foxy