Why is Rails 4 not uninstalled?

After uninstalling Rails 4 (RC1), I still get Rails 4 applications created with rails new .

 ➲ rails -v Rails 4.0.0.rc1 ➲ which rails /Users/brandon/.rvm/gems/ruby-1.9.3-p392/bin/rails ➲ gem uninstall rails Select gem to uninstall: 1. rails-3.2.13 2. rails-3.2.3 3. All versions > 

What is the cleanest way to fix this?

+6
source share
5 answers

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.

+1
source

It is pretty simple.

 gem uninstall rails -v=4.0.0.rc1 gem uninstall railties gem install rails -v 3.2.13 gem update --system rails -v 

Using the above commands, I was able to install an older version of the rails as needed :)

+10
source

Try to specify the installed version:

 gem uninstall rails -v=4.0.0.rc1 

EDIT:

If you have already deleted (you have), follow these steps:

 gem update --system rails _3.2.2_ new app_name # or whatever version you're on 
+2
source

Rails does not come as an all-in-one package. You have a basic Rails stone, plus many dependencies:

  • Action mailer
  • Action pack
  • Active record
  • Active resource
  • Active support
  • Bundler
  • Railties <---- (contains generators)
  • Star Adapter for Rails

To get rid of the installation of Rails 4 in general, you must remove all these gems.

The easiest way to do this is to delete the entire gem folder , and then reinstall everything you need.

+2
source

Fortunately, this worked as a simple fix for me:

Please note that in order to return to 3.2.13 (or any other option that you would like to return to), you must remove Railties, as well as Rails.

Just do:

gem uninstall rails

Then select the version of Rails 4 that you have and uninstall it.

Then do:

gem uninstall railties

And do the same.

When I removed the Rails 4 railties version, he told me that dependencies for a pair of gems (coffee rails and sassi rails) would not be fulfilled. So I did the same with both of them as above (for example, gem uninstall sass-rails ), and uninstalled their Rails 4 versions. For example, for sass-rails I had sass-rails-4.0 installed. 0.rc1, so I uninstalled this version).

What is it; the terminal will display 3.2.13 as the current version of Rails, and new applications will also be created from this version.

+1
source

Source: https://habr.com/ru/post/946464/


All Articles