0

我有 2 个使用 RVM 的红宝石版本,我正在尝试删除我在这个红宝石中的所有宝石version 1.8.7-p302

首先我尝试了这个,但我得到了错误

➜  ~  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`

然后我尝试了这也是一个错误

➜  ~  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`

我的宝石清单:

➜  ~  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)

更新:

我试图删除 ruby​​ 1.8.7 然后安装它但是当我输入时宝石仍然存在我得到了这个

➜  ~  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

现在我不能再安装导轨了!

➜  ~  gem rails -v '2.3.5'
ERROR:  While executing gem ... (RuntimeError)
    Unknown command rails
4

2 回答 2

4

使用 RVM

1) 安装 rvm。

在其余步骤中:

永远不要使用 SUDO

2)安装红宝石(选择一个版本):

$ rvm install 1.9.3

3) 确保 rvm 的当前 ruby​​ 是您要用于您的应用程序的版本:

$ rvm list

如有必要:

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

4) 为您的应用创建 gemset:

$ rvm gemset create myapp_gemset

5) 您可以列出当前 ruby​​ 版本的 gemsets:

$ rvm gemset list

如有必要,切换到您刚刚创建的 gemset:

$ rvm gemset use myapp_gemset

6)安装rails gem:

$ gem install rails --version 4.0.0

该命令会将 gem 安装到当前 gemset 中。您可以检查版本:

$ rails -v

您可以使用一个快捷方式来选择 ruby​​ 版本和您之前为该 ruby​​ 版本创建的 gemset:

$ rvm use 1.9.3-p194@myapp_gemset

您还可以设置一个默认的 ruby​​ 和 gemset,当您打开一个新的终端窗口时将选择它们:

$ rvm use 1.9.3-p194@myapp_gemset --default

或者,您可以在应用程序中设置 Gemfile,以便 rvm 在您将目录更改为应用程序目录时切换到指定的 ruby​​ 版本和 gemset:

宝石文件:

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

rvm 将在您的 Gemfile 中读取该注释,然后切换到上一行的 ruby​​ 版本和注释中指定的 gemset。

. .

https://rvm.io/gemsets/deleting

删除宝石

当您删除 gemset 时,rvm 会提示您确认删除。

$ rvm gemset use albinochipmunk
$ rvm gemset delete albinochipmunk

要跳过确认,请传递 --force 标志:

$ 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
于 2013-08-20T16:39:00.247 回答
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

于 2013-08-20T17:00:37.080 回答