0

I have 2 versions of rubies using RVM and i am trying to remove all my gems which in this ruby version 1.8.7-p302

first i tried this but i got error

➜  ~  gem list | cut -d" " -f1 | xargs gem uninstall -aIx
Successfully uninstalled actionmailer-2.3.5
Successfully uninstalled actionmailer-2.3.18
Successfully uninstalled actionpack-2.3.5
Successfully uninstalled actionpack-2.3.18
Successfully uninstalled activerecord-2.3.5
Successfully uninstalled activerecord-2.3.18
Successfully uninstalled activeresource-2.3.5
Successfully uninstalled activeresource-2.3.18
Successfully uninstalled activesupport-2.3.5
Successfully uninstalled activesupport-2.3.18
Removing bundle
Successfully uninstalled bundler-1.3.5
ERROR:  While executing gem ... (Gem::InstallError)
    cannot uninstall, check `gem list -d bundler-unload`

then i tried this also an error

➜  ~  gem list --no-version | xargs gem uninstall -aIx
zsh: correct 'gem' to '.gem' [nyae]? n
ERROR:  While executing gem ... (Gem::InstallError)
    cannot uninstall, check `gem list -d bundler`

My Gemlist:

➜  ~  gem list                                                                                 

*** LOCAL GEMS ***

bundler (1.3.5)
bundler-unload (1.0.1)
declarative_authorization (0.5.1)
fattr (2.2.1)
i18n (0.4.2)
mysql (2.9.1, 2.8.1)
rack (1.1.6, 1.0.1)
rails (2.3.18, 2.3.5)
rake (10.1.0, 0.8.7)
rubygems-bundler (1.2.2)
rush (0.6.8)
rvm (1.11.3.8)
session (3.1.0)
sqlite3 (1.3.8)

Update:

I have tried to remove ruby 1.8.7 then install it but the gems still there when i type i got this

➜  ~  rvm gemset empty default
Are you SURE you wish to remove the installed gems for gemset 'ruby-1.8.7-p302' (/home/dexter/.rvm/gems/ruby-1.8.7-p302)?
(anything other than 'yes' will cancel) > yes
➜  ~  gem list

*** LOCAL GEMS ***

bundler (1.3.5)
bundler-unload (1.0.1)
rake (10.1.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
➜  ~  gem list --no-version | xargs gem uninstall -aIx   
zsh: correct 'gem' to '.gem' [nyae]? n
INFO:  gem "bundler" is not installed
INFO:  gem "bundler-unload" is not installed
INFO:  gem "rake" is not installed
INFO:  gem "rubygems-bundler" is not installed
INFO:  gem "rvm" is not installed

Now i can not install rails again !

➜  ~  gem rails -v '2.3.5'
ERROR:  While executing gem ... (RuntimeError)
    Unknown command rails
Mostafa Hussein
  • 8,657
  • 3
  • 27
  • 51

2 Answers2

4

USING RVM

1) Install rvm.

In the rest of the steps:

DON'T EVER USE SUDO

2) Install ruby (pick a version):

$ rvm install 1.9.3

3) Make sure rvm's current ruby is the version you want to use for your app :

$ rvm list

and if necessary:

$ rvm use 1.9.3-p194  #Sometimes you have to specify the patch number as well, e.g p194

4) Create a gemset for your app:

$ rvm gemset create myapp_gemset

5) You can list the gemsets for the current ruby version:

$ rvm gemset list

and if necessary switch to the gemset you just created:

$ rvm gemset use myapp_gemset

6) Install the rails gem:

$ gem install rails --version 4.0.0

That command will install the gem into the current gemset. You can check the version:

$ rails -v

There is a shortcut you can use to select the ruby version and a gemset you previously created for that ruby version:

$ rvm use 1.9.3-p194@myapp_gemset

You can also set a default ruby and gemset that will be selected when you open a new terminal window:

$ rvm use 1.9.3-p194@myapp_gemset --default

Or, you can set up your Gemfile in your app so that rvm switches to the specified ruby version and gemset when you change directories into your app's directory:

Gemfile:

ruby '1.9.3'   #(no patch number allowed here)
#ruby-gemset=myapp_gemset

rvm will read that comment in your Gemfile, and then switch to the ruby version on the previous line and the gemset specified in the comment.

. .

https://rvm.io/gemsets/deleting

Deleting Gemsets

When you delete a gemset, rvm will prompt you to confirm the deletion.

$ rvm gemset use albinochipmunk
$ rvm gemset delete albinochipmunk

To skip confirmation, pass the --force flag:

$ rvm gemset use albinochipmunk
$ rvm --force gemset delete albinochipmunk

By default, rvm deletes gemsets from the currently selected Ruby interpreter. To delete a gemset from a different interpreter, say 1.9.2, run your command this way:

$ rvm 1.9.2 do gemset delete albinochipmunk

.

If you don't use a gemset at all, you get the gems in the 'default' set

.

https://rvm.io/gemsets/emptying

Emptying Gemsets

If you empty a gemset, rvm will prompt you for confirmation. This action removes all gems installed in the gemset.

$ rvm gemset use albinochipmunk 
$ rvm gemset empty albinochipmunk 

To skip confirmation, pass the --force flag:

$ rvm gemset use albinochipmunk 
$ rvm --force gemset empty albinochipmunk
7stud
  • 42,113
  • 12
  • 85
  • 111
  • i did not use a gem set ! , all i do is install a ruby version 1.8.7 then gem install rails -v 2.3.5 – Mostafa Hussein Aug 20 '13 at 16:50
  • See additions to my post--you should empty the default gemset. – 7stud Aug 20 '13 at 16:58
  • If you switch to a version of ruby `$ rvm use 1.8.7-p302`, then do `$ rvm gemset list`, you will see all the gemsets for that version. The default and global gemsets are created automatically for you. You probably shouldn't delete them. If you switch to a gemset `$ rvm gemset use mygemsA` you can then see all the gems in the gemset by doing `$ gem list`. That will allow you to confirm whether all your gems went into the default gemset. – 7stud Aug 20 '13 at 17:05
  • see my update, i think i have to uninstall rvm to start from the beginning :S – Mostafa Hussein Aug 20 '13 at 17:16
  • Removing rvm: http://stackoverflow.com/questions/3558656/how-to-remove-rvm-ruby-version-manager-from-my-system – 7stud Aug 20 '13 at 17:29
  • `Now i can not install rails again!` Well, you have to use the right commands, and `$ gem rails -v '2.3.5'` ain't it. Why all the panic? Why do all beginners think the first course of action is delete/remove/erase? Heck I'm surprised you didn't do: `$ cd /` and then `$ rm -rf` to wipe your whole hard drive and then reinstall your whole operating system again. – 7stud Aug 20 '13 at 17:40
  • And did you even create a gemset before trying to install the rails gem? – 7stud Aug 20 '13 at 17:44
  • i just typed the first command of the solution in that link you gave then deleted the configuration from .zshrc and re-installed rvm again then i have installed rails 1.9.3 again but there is a gem list but does not include rails gem , i am installing it again , also i will re-install 1.8.7 i hope i wont get errors with it , also i did not create any gemset before installing rails – Mostafa Hussein Aug 20 '13 at 18:09
  • Okay, you NEED to create a gemset. That is how you organize gems for your apps. Each app gets its own gemset. So after installing rvm, then install a ruby `rvm install 1.9.3`. Then make sure the current ruby is the version you want to use for your app `$ rvm list` and if necessary, `$ rvm use 1.9.3-p194`. Then the first thing you should do is....CREATE A GEMSET: `rvm gemset create myapp_gemset` (continued below) – 7stud Aug 20 '13 at 20:10
  • Then you can list the gemsets for the current ruby `$ rvm gemset list` and if necessary switch to the gemset you just created `$ rvm gemset use myapp_gemset`. Then you install the rails gem `$ gem install rails --version 4.0.0`. That command will install the gem into the current gemset. – 7stud Aug 20 '13 at 20:10
0

RVM installs some gems in the global gemset you can uninstall those gems with:

rvm @global do gem uninstall gem_name

if you do not want to use any gemsets (except the single per ruby gemset) use: this:

echo rvm_ignore_gemsets_flag=1 >> ~/.rvmrc

and from now on RVM will use only single gemset - no global

mpapis
  • 51,279
  • 14
  • 117
  • 159