How to remove a version fo Rails - ruby-on-rails

It looks like I have installed multiple version of rails :
rails (6.0.0, 5.1.7, 5.1.6.2)
I would like to remove the most recent one, 6.0.0 which I installed in order to use action text, but I realise that it requires me to do quite a few changes.
How can I simply do that please ?
When I do:
$ gem uninstall rails -v 6.0.0
I get :
ERROR: While executing gem ... (Gem::InstallError)
rails is not installed in GEM_HOME, try:
gem uninstall -i /Users/elandron/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0 rails
When i do : / -type d -name rails-6.0.0 , i get
/Users/elandron/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/doc/rails-6.0.0
/Users/elandron/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/rails-6.0.0
/Users/elandron/.rvm/gems/ruby-2.6.3/doc/rails-6.0.0

The following worked for me at the end:
sudo gem uninstall rails -v 4.1.1
Then when running gem list, I only see the version that I wanted.

Related

Cannot run rails

rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I have oh-my-zsh installed.
which rails
/usr/bin/rails
How I export PATH in ~/.zshrc:
export PATH=$HOME/bin:/usr/local/bin:/usr/bin:$PATH
When I try to install rails it looks like it's not installing anything (note '0' seconds):
sudo gem install rails
Successfully installed rails-6.0.3.3
Parsing documentation for rails-6.0.3.3
Done installing documentation for rails after 0 seconds
1 gem installed
Any idea why this is happening and how I can fix it?
Seem you have problem with rails -v
If you can, use google translate and try to refer this link https://qiita.com/aki319809/items/9de7f14285cd0c69e2d2

Issue upgrading to Rails 5.1.4

I attempt to upgrade to Rails 5.1.4. Seems to update without an issue, however, a version check still shows 5.0.4. Any ideas?
Ruby Version:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Terminal Output:
$ rails -v
Rails 5.0.4
$ gem install rails --version=5.1.4
Successfully installed rails-5.1.4
Parsing documentation for rails-5.1.4
Done installing documentation for rails after 0 seconds
1 gem installed
$ rails -v
Rails 5.0.4
Uninstall all versions of rails installed in your system by:
gem uninstall rails
It should prompt you with something like below
Select gem to uninstall:
1. rails-4.2.6
2. rails-5.1.4
3. All versions
Choose Option "All Versions" and uninstall all
Install the desired rails version:
gem install rails --version=5.1.4
rails -v
5.1.4
Update: Since you mentioned using bundle install, check if rails is specified with 5.1.4 in your Gemfile or not.
Sometimes, i met this problem, because you have two versions of rails in your railties. You can do this
gem uninstall railties
Select gem to uninstall:
1. railties-5.1.4
2. railties-5.0.4
3. All versions
Type 3 to remove all, then you can reinstall rails 5.1.4 again.
Either use
bin/rails -v
or
bundle exec rails -v
to select the version of rails specified in your Gemfile
Or do what I do and install https://direnv.net/ and add a .envrc file to the project. Then when you cd to that project, the path will be updated appropriately and rails -v will work as expected:
PATH_add "./bin"

Uninstalling rails from command line

I am trying to uninstall rails from my computer.Whenever I run the command gem uninstall rails ,it gives me the following error
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check gem list -d rails
Does this cover your question?
Uninstall Rails completely
It is possible that you have multiple versions of Rails installed in your system. Thus, that command might have failed by not deciding which Rails version you intended to remove.
Check your Rails versions by running gem list -d rails or gem list | grep rails and note the versions (Example, I have 3.2.8, 3.2.5, 4.0.0).
To uninstall any version use:
gem uninstall rails -v 3.2.8

Rails command working , rails -v shows Rails 4.0.0 , gem list rails shows 3.2.13

Rails command is working . rails -v shows 4.0.0 . gem list rails shows 3.2.13 . I want to work on rails 3.2.13 , when i tried to uninstall rails 4.0.0 it says gem "rails" is not installed .What should i do so that rails -v shows 3.2.13 and rails 4 get uninstalled ?
It's because the Rails binary actually loads itself via the railties gem. The last two lines of /usr/local/bin/rails looks something like:
gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
You need to run:
gem uninstall railties -v 4.0.0
Assuming you have Rails & Railties 3.2.13 installed, rails -v should now return Rails 3.2.13.
I don't know why you want remove rails 4, if you are already using rvm you should easily switch between ruby/rails versions without any problem, if you don't know rvm i recommend you to read why-you-should-use-rvm
if you should remove obligatory rails 4.0.0 try this command :
gem uninstall rails --version 4.0.0
if this can't solve your problem please add more details in your question
It's probably the best way to use rvm https://rvm.io/rvm/install
I had the same problem a week ago.
try gem uninstall rails -v=4.0.0.
or
gem uninstall rails
then install rvm using:
\curl -L https://get.rvm.io | bash
and then
\curl -L https://get.rvm.io | bash -s stable --rails
and
gem install rails --version '~> 3.2.0'

Updating to Rails 3 on Mac OS X

While trying to install Rails 3, I get the following error:
command run: sudo gem install rails --pre
error'd now with:
Successfully installed rails-3.0.0.rc2
1 gem installed
Installing ri documentation for rails-3.0.0.rc2...
File not found: lib
Or if you don't want to worry about running versions side by side you can do
gem update rails
At least it worked for me.
Rails 3 is out of beta/rc now, so try:
gem install rails --version 3.0.0
It should work on Ruby 1.8.7 and 1.9.2-p0.
I haven't personally seen that issue, but you could try and get around it by using the --no-ri option.
sudo gem install rails --pre --no-ri
There's also a --no-rdoc option if you have trouble with that too.

Resources