DEV Community

Daniel
Daniel

Posted on

Fixing "g++ Not Found" When Debugging Rails in RubyMine on Fedora

Fixing "g++ Not Found" When Debugging Rails in RubyMine on Fedora

TL;DR: If clicking "Debug" in RubyMine on Fedora fails to install debase because of a missing g++ compiler, the standard @development-tools group might not be enough. Run sudo dnf install gcc-c++ make redhat-rpm-config to get the explicit C++ compiler and tools Ruby needs to build native extensions.


I was recently working on a Rails app on my Fedora machine and wanted to step through some code. I fired up RubyMine, set my breakpoints, and clicked the "Debug" button, fully expecting everything to just work.

Instead, RubyMine tried to automatically install the debase and ruby-debug-ide gems—which it needs under the hood to hook into the Ruby process—and threw a massive wall of error text at me.

The core of the failure looked like this:

Building native extensions. This could take a while...
ERROR:  Error installing debase-3.0.17.gem:
    ERROR: Failed to build gem native extension.
...
/path/to/extconf_common.rb:80:in 'Kernel#`': No such file or directory - g++ (Errno::ENOENT)
Enter fullscreen mode Exit fullscreen mode

My system was essentially complaining that it couldn't find g++, the C++ compiler.

The Initial (Failed) Attempt

My first thought was, "Oh, I must have forgotten to install the base build tools on this machine."

Since I'm on Fedora, I reached for the standard DNF command to pull in the development group:

sudo dnf install @development-tools
Enter fullscreen mode Exit fullscreen mode

(Note: If you're on older versions of Fedora, you might be used to dnf groupinstall "Development Tools", but DNF5 uses the @ syntax or space-separated group install).

It downloaded and installed a bunch of packages. I felt confident, went back to RubyMine, clicked "Debug" again, and... got the exact same No such file or directory - g++ error.

Why Didn't That Work?

When you install Ruby gems that contain native C or C++ extensions (like debase), Ruby doesn't just download a pre-built binary. It actually compiles the raw source code down to machine code directly on your machine so it runs as fast as possible.

While the @development-tools group pulls in a ton of great utilities like git, make, and standard gcc (for C code), it doesn't always explicitly guarantee that the C++ compiler (g++) and Red Hat-specific RPM configuration headers are placed right where Ruby's extconf.rb script is looking for them on a fresh environment.

Without g++ explicitly available in the PATH, the compilation halts immediately.

The Actual Fix

To fix this, I needed to bypass the generic group install and specifically target the C++ toolchain and the Red Hat configuration files that native Ruby extensions rely on.

I ran this command:

sudo dnf install gcc-c++ make redhat-rpm-config
Enter fullscreen mode Exit fullscreen mode

To verify it worked, I double-checked that my shell could now see the compiler:


bash
which g++
# Output: /usr/bin/g++
Enter fullscreen mode Exit fullscreen mode

Top comments (0)