Warning

You're reading the documentation for a version of ROS 2 that has reached its EOL (end-of-life), and is no longer officially supported. If you want up-to-date information, please have a look at Jazzy.

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 Sierra (10.12.x).

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 python3
    
    # 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
    
    # 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 lark-parser lxml 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

  • Download ROS 2 Dashing Diademata - Patch Release 4 for macOS; let’s assume that it ends up at ~/Downloads/ros2-release-distro-date-macos-amd64.tar.bz2.

    • Note: OSX binary builds are only provided for Dashing up until ROS 2 Dashing Diademata - Patch Release 4 due to changes with OSX and/or homebrew that made it difficult to target OSX Sierra.

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

  • Unpack it:

    mkdir -p ~/ros2_dashing
    cd ~/ros2_dashing
    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_dashing/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!

Next steps after installing

Continue with the tutorials and demos to configure your environment, create your own workspace and packages, and learn ROS 2 core concepts.

Using the ROS 1 bridge

The ROS 1 bridge can connect topics from ROS 1 to ROS 2 and vice-versa. See the dedicated documentation on how to build and use the ROS 1 bridge.

Additional RMW implementations (optional)

The default middleware that ROS 2 uses is Fast-RTPS, but the middleware (RMW) can be replaced at runtime. See the guide on how to work with multiple RMWs.

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 Dashing 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_dashing