Fixing "environment variable ‘RPM_ARCH’ not defined" error when building ROS 2 on Fedora Linux

2024-09-22

How to resolve the "environment variable ‘RPM_ARCH’ not defined" error when building any ROS 2 version from source on Fedora Linux.

>

This solution isn't just for ROS 2. If you're following RPM installation instructions on Fedora and encounter a similar scenario, you can apply this workaround from the oolite repository with some adjustments.

# 🤖 Building ROS 2 from source on Fedora Linux

Based on the version of ROS 2 you want to install, visit the official documentation page. For Humble, click here. Open the Installation dropdown menu. Inside, you'll find another dropdown called Alternatives. Select it to find the Fedora (source) subpage.

If you don't find the Fedora (source) subpage, as is the case with the latest ROS 2 version, Jazzy Jalisco, you'll need to follow the instructions on the RHEL (source) subpage, where you'll also find details for Fedora.

Once you’re on the correct page, follow all instructions up to the "Build the code in the workspace" section. At this point, you may encounter one or both of these errors, or something similar, while attempting to build:

g++: fatal error: environment variable ‘RPM_ARCH’ not defined
# --- or/and ---
g++: fatal error: environment variable ‘RPM_PACKAGE_RELEASE’ not defined

## 🔧 How to fix this error with a simple workaround

Before building ROS 2, run the following export commands:

export RPM_ARCH=$(uname -m)
export RPM_PACKAGE_RELEASE=1.0
export RPM_PACKAGE_VERSION=1.0
export RPM_PACKAGE_NAME=qt_gui_cpp

After running these commands (or saving them in your environment for future use), you should be able to build successfully.

Note that you can assign any values you want; the key is simply to define these variables so they point to something valid.

## 🎉 Conclusion

With this workaround, you should now be able to build ROS 2, or any other program facing this issue, without any further problems.

All posts

kosu.me 🐧 - 2024