TL DR:
The simplest and safest solution to an immediate problem is
gem uninstall railties
A slightly longer and more complete approach
If you want to remove everything that gem install rails installed, you can get a list of commands to run with this:
gem dependency rails --pipe | ruby -ne 'puts $_.gsub(/\([0-9\. <>=~,]*\)/,"")' | ruby -ne 'puts "gem uninstall #{$_}"'
Copy them and run them one by one, and for each of them you will be told what else depends on it, and asked if you want to continue the removal. If you see something on the list that is not part of the rails (let's say you installed something else that needs this version of active_record ), leave it, otherwise go and delete.
Longer explanation
The displayed version is taken from the railties gem version, which is not removed by removing the rails stone.
If you open rails executable with
vim `which rails`
(or the equivalent with the selected editor) you will see the code below that decides which version of the rails to use based on the railties version:
#!/usr/bin/env ruby_noexec_wrapper # # This file was generated by RubyGems. # # The application 'railties' is installed as part of a gem, and # this file is here to facilitate running it. # require 'rubygems' version = ">= 0" if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding if str =~ /\A_(.*)_\z/ version = $1 ARGV.shift end end gem 'railties', version load Gem.bin_path('railties', 'rails', version)
The simplest solution is therefore only valid for gem install railsties . There is no solution built into RubyGems (which I can find) that will detect which other stones have been installed with rails and are no longer used by anyone else , and delete them. RubyGems has no concept of exclusive dependency, so while nothing but rails uses railties , you still need to know that it (and a few other things) is left and needs to be removed manually. This is not ideal, but it is what we have right now, and it is not so bad, especially if you use the solution above to find and remove all rail dependencies.
source share