How to Properly Uninstall Ruby Installed from Source on Fedora Linux


2 views

When you compile Ruby from source (like Ruby 1.9 in this case), the installation doesn't always include an uninstall target in the Makefile. This differs from package manager installations (like yum) which maintain proper metadata for clean removal.

Here's how to completely remove a source-installed Ruby version:


# First, find where Ruby was installed
which ruby
# Typically /usr/local/bin/ruby or /opt/ruby/bin/ruby

# Check the installation prefix
ruby -r rbconfig -e 'puts RbConfig::CONFIG["prefix"]'

# Remove all files under the prefix
sudo rm -rf /usr/local/lib/ruby
sudo rm -rf /usr/local/include/ruby
sudo rm -rf /usr/local/share/ri

# Remove binaries
sudo rm /usr/local/bin/ruby
sudo rm /usr/local/bin/irb
sudo rm /usr/local/bin/gem
sudo rm /usr/local/bin/rake
# ... and any other Ruby-related binaries

For future source installations, consider using checkinstall which creates a package that can be uninstalled:


sudo yum install checkinstall
./configure
make
sudo checkinstall
# Later you can remove with:
sudo rpm -e ruby-1.9.x

After removing your source installation, you can install the system Ruby package:


sudo yum install ruby ruby-devel
# Verify version
ruby -v
# Should show 1.8.6 or similar

For better Ruby version management, consider using rbenv or RVM instead of manual source installs:


# Using rbenv example:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
rbenv install 1.8.6-p420
rbenv global 1.8.6-p420

When you compile Ruby from source (like Ruby 1.9 in this case), the installation doesn't always include an uninstall target in the Makefile. This is different from package manager installations (like yum/dnf) which maintain proper dependency tracking and uninstallation routines.

First, let's locate all files installed by the source installation:

# Find files installed via make install
sudo find / -type f -name "*ruby*" -o -name "*1.9*" | grep -v "/usr/lib/ruby" | grep -v "/var/lib"

# Check installation prefix (usually /usr/local)
ls -la /usr/local/bin/ruby*
ls -la /usr/local/lib/ruby

Based on a standard Ruby source installation, here are the typical locations to clean:

# Binaries
sudo rm -f /usr/local/bin/ruby
sudo rm -f /usr/local/bin/irb
sudo rm -f /usr/local/bin/gem
sudo rm -f /usr/local/bin/rake

# Libraries
sudo rm -rf /usr/local/lib/ruby/1.9.3

# Headers
sudo rm -rf /usr/local/include/ruby-1.9.3

# Man pages
sudo rm -f /usr/local/share/man/man1/ruby.1
sudo rm -f /usr/local/share/man/man1/irb.1

After removal, verify Ruby 1.9 is completely gone:

which ruby
ruby -v
gem list

Now install the older version through the package manager:

sudo yum install ruby ruby-libs ruby-devel

# Verify installation
ruby -v
# Should show 1.8.6 or similar

For future Ruby version management, consider using RVM (Ruby Version Manager):

# Install RVM
\curl -sSL https://get.rvm.io | bash -s stable

# List available Ruby versions
rvm list known

# Install specific version
rvm install 1.8.6
rvm use 1.8.6 --default

When installing from source, consider these best practices:

  • Always use ./configure --prefix=/opt/ruby-1.9.3 for custom installations
  • Keep track of make install output which lists installed files
  • Consider using checkinstall to create a package instead of direct installation