【问题标题】:Uninstall Rails completely完全卸载 Rails
【发布时间】:2013-04-23 08:38:47
【问题描述】:

我正在尝试完全卸载 Rails,但我无法掌握它。

这是我尝试过的:

$ gem update
rails 4.0.0.beta1 installed

$ rails -v
Rails 4.0.0.beta1

$ gem uninstall rails -v 4.0.0.beta1

但仍然:

$ rails -v
Rails 4.0.0.beta1

我怎样才能完全删除 rails 版本?

【问题讨论】:

  • gem uninstall rails -v 4.0.0.beta1 的输出是什么?
  • 你解决了这个问题吗?我遇到了和你一样的问题。
  • 好吧,我终于解决了这个问题,看我的cmets如下

标签: ruby-on-rails


【解决方案1】:

最终解决方案

只需卸载 railties -v 4.0.0,一切正常。

$ which rails
~/software/bin/rails
$ rails -v
Rails 4.0.0
$ gem list | grep rails
rails (4.0.0, 3.2.13, 3.2.9, 3.2.6)
$ gem uninstall rails -v 4.0.0

You have requested to uninstall the gem:
        rails-4.0.0
figaro-0.7.0 depends on [rails (< 5, >= 3)]
.....
.....
Continue with Uninstall? [Yn]  y
Successfully uninstalled rails-4.0.0
$ gem list | grep rails
rails (3.2.13, 3.2.9, 3.2.6)
$ rails  -v
Rails 4.0.0
$ gem uninstall railties -v 4.0.0

You have requested to uninstall the gem:
        railties-4.0.0
coffee-rails-4.0.0 depends on [railties (< 5.0, >= 4.0.0.beta)]
....
....
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  y
Successfully uninstalled railties-4.0.0
$ rails -v
Rails 3.2.13

看! rails版本恢复正常!!

这里的原因:

$ tail `which rails`
  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)

早点尝试

嗯,我做了所有我在互联网上找到的东西,但没有任何效果。我只是删除 gem 文件夹,安装 rails 3.2.12,它就可以工作了...
已安装所有 31 个 gem

# rm -rf /usr/local/lib/ruby/gems/
# gem list

*** LOCAL GEMS ***
# gem cleanup
Cleaning up installed gems...
Clean Up Complete
# gem update --system
# gem install rails -v 3.2.12
Fetching: i18n-0.6.5.gem (100%)
Successfully installed i18n-0.6.5
Fetching: multi_json-1.8.2.gem (100%)
Successfully installed multi_json-1.8.2
Fetching: activesupport-3.2.12.gem (100%)
Successfully installed activesupport-3.2.12
Fetching: builder-3.0.4.gem (100%)
Successfully installed builder-3.0.4
Fetching: activemodel-3.2.12.gem (100%)
Successfully installed activemodel-3.2.12
Fetching: rack-1.4.5.gem (100%)
Successfully installed rack-1.4.5
Fetching: rack-cache-1.2.gem (100%)
Successfully installed rack-cache-1.2
Fetching: rack-test-0.6.2.gem (100%)
Successfully installed rack-test-0.6.2
Fetching: journey-1.0.4.gem (100%)
Successfully installed journey-1.0.4
Fetching: hike-1.2.3.gem (100%)
Successfully installed hike-1.2.3
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: sprockets-2.2.2.gem (100%)
Successfully installed sprockets-2.2.2
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: actionpack-3.2.12.gem (100%)
Successfully installed actionpack-3.2.12
Fetching: arel-3.0.2.gem (100%)
Successfully installed arel-3.0.2
Fetching: tzinfo-0.3.38.gem (100%)
Successfully installed tzinfo-0.3.38
Fetching: activerecord-3.2.12.gem (100%)
Successfully installed activerecord-3.2.12
Fetching: activeresource-3.2.12.gem (100%)
Successfully installed activeresource-3.2.12
Fetching: mime-types-1.25.gem (100%)
Successfully installed mime-types-1.25
Fetching: polyglot-0.3.3.gem (100%)
Successfully installed polyglot-0.3.3
Fetching: treetop-1.4.15.gem (100%)
Successfully installed treetop-1.4.15
Fetching: mail-2.4.4.gem (100%)
Successfully installed mail-2.4.4
Fetching: actionmailer-3.2.12.gem (100%)
Successfully installed actionmailer-3.2.12
Fetching: rake-10.1.0.gem (100%)
Successfully installed rake-10.1.0
Fetching: rack-ssl-1.3.3.gem (100%)
Successfully installed rack-ssl-1.3.3
Fetching: thor-0.18.1.gem (100%)
Successfully installed thor-0.18.1
Fetching: json-1.8.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed json-1.8.0
Fetching: rdoc-3.12.2.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed rdoc-3.12.2
Fetching: railties-3.2.12.gem (100%)
Successfully installed railties-3.2.12
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
Fetching: rails-3.2.12.gem (100%)
Successfully installed rails-3.2.12
... rdoc stuff  ...
31 gems installed

这里有些奇怪

我有$ sudo gem uninstall rails -v 4.0.0$ sudo gem cleanup 并安装rails 3.2.13 ($ sudo gem install rails -v 3.2.13),只安装了15 个宝石

$ sudo gem install rails -v 3.2.13
Fetching: i18n-0.6.1.gem (100%)
Fetching: activesupport-3.2.13.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.13.gem (100%)
Fetching: rack-1.4.5.gem (100%)
Fetching: sprockets-2.2.2.gem (100%)
Fetching: actionpack-3.2.13.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.38.gem (100%)
Fetching: activerecord-3.2.13.gem (100%)
Fetching: activeresource-3.2.13.gem (100%)
Fetching: actionmailer-3.2.13.gem (100%)
Fetching: rdoc-3.12.2.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Fetching: railties-3.2.13.gem (100%)
Successfully installed i18n-0.6.1
Successfully installed activesupport-3.2.13
Successfully installed builder-3.0.4
Successfully installed activemodel-3.2.13
Successfully installed rack-1.4.5
Successfully installed sprockets-2.2.2
Successfully installed actionpack-3.2.13
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.38
Successfully installed activerecord-3.2.13
Successfully installed activeresource-3.2.13
Successfully installed actionmailer-3.2.13
Successfully installed rdoc-3.12.2
Successfully installed railties-3.2.13
Successfully installed rails-3.2.13
15 gems installed
... rdoc stuff ...

还有rails -v:

$ rails -v
/usr/local/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find minitest (~> 4.2) amongst [actionmailer-4.0.0, actionmailer-3.2.13, actionpack-4.0.0, actionpack-3.2.13, activemodel-4.0.0, activemodel-3.2.13, activerecord-4.0.0, activerecord-3.2.13, activerecord-deprecated_finders-1.0.3, activeresource-4.0.0, activeresource-3.2.13, activesupport-4.0.0, activesupport-3.2.13, addressable-2.3.3, arel-4.0.0, arel-3.0.2, atomic-1.1.14, bcrypt-ruby-3.0.1, better_errors-0.8.0, bigdecimal-1.2.1, binding_of_caller-0.7.1, bootstrap-sass-2.3.1.0, builder-3.2.2, builder-3.0.4, bundler-1.3.5, cancan-1.6.9, capybara-2.0.3, childprocess-0.3.9, coderay-1.0.9, coffee-rails-4.0.0, coffee-script-2.2.0, coffee-script-source-1.6.3, countries-0.9.2, cucumber-1.2.3, cucumber-rails-1.3.1, currencies-0.4.0, database_cleaner-1.0.0.RC1, debug_inspector-0.0.2, devise-2.2.3, diff-lcs-1.2.2, email_spec-1.4.0, erubis-2.7.0, execjs-2.0.2, factory_girl-4.2.0, factory_girl_rails-4.2.1, ffi-1.6.0, figaro-0.6.3, gherkin-2.11.6, hike-1.2.3, httpclient-2.3.3, httpi-2.0.2, i18n-0.6.5, i18n-0.6.1, io-console-0.4.2, jbuilder-1.5.1, journey-1.0.4, jquery-rails-3.0.4, json-1.8.0, launchy-2.2.0, libv8-3.16.14.3, mail-2.5.4, mime-types-1.25, minitest-5.0.8, multi_json-1.8.1, mysql2-0.3.13, nokogiri-1.5.9, orm_adapter-0.4.0, polyglot-0.3.3, quiet_assets-1.0.2, rack-1.5.2, rack-1.4.5, rack-cache-1.2, rack-ssl-1.3.3, rack-test-0.6.2, rails-3.2.13, rails-observers-0.1.2, railties-4.0.0, railties-3.2.13, rake-10.1.0, rdoc-4.0.1, rdoc-3.12.2, recurly-2.1.8, ref-1.0.5, rolify-3.2.0, rspec-core-2.13.1, rspec-expectations-2.13.0, rspec-mocks-2.13.0, rspec-rails-2.13.0, rubyzip-0.9.9, sass-3.2.12, sass-rails-4.0.0, sdoc-0.3.20, selenium-webdriver-2.31.0, simple_form-2.1.0, sprockets-2.10.0, sprockets-2.2.2, sprockets-rails-2.0.0, therubyracer-0.12.0, thor-0.18.1, thread_safe-0.1.3, tilt-1.4.1, treetop-1.4.15, turbolinks-1.3.0, tzinfo-1.1.0, tzinfo-0.3.38, uglifier-2.2.1, warden-1.2.1, websocket-1.0.7, xpath-1.0.0] (Gem::LoadError)
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:777:in `block in activate_dependencies'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:780:in `block in activate_dependencies'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from /usr/local/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from /usr/local/lib/ruby/1.9.1/rubygems.rb:1232:in `gem'
    from /usr/local/bin/rails:22:in `<main>'

无法通过完全卸载来删除 Rails 4.0.0,这是一个错误吗?

【讨论】:

  • 什么是有线的?我认为有一个错字。
  • 谢谢,这解决了我的问题!应该是公认的解决方案。
  • 谢谢,还帮我卸载了 Rails,用于降级 :)
【解决方案2】:

从系统中完全移除导轨的 2 个步骤

1) gem uninstall rails
2)gem uninstall railties

选择您要卸载的版本。

【讨论】:

    【解决方案3】:

    万一其他人来了,我发现我也必须卸载railties

    gem uninstall railties
    

    /~user 向下检查您可能安装过 rails 的所有目录

    【讨论】:

      【解决方案4】:

      如果您使用的是 rvm,您可以通过删除 $HOME 中的 .gem 目录来卸载所有 gems

      rm -rf ~/.gem

      或仅卸载 rails:

      gem 卸载 -a rails

      或者如果您使用 sudo 安装:

      sudo gem 卸载 -a rails

      【讨论】:

        【解决方案5】:

        您尚未指定要卸载的 gem,请尝试 gem uninstall rails

        【讨论】:

        • 我写道:gem uninstall rails -v 4.0.0.beta1 ( gem uninstall rails -v=4.0.0.beta1)
        【解决方案6】:
        sudo gem uninstall rails -v 4.0.0.beta1
        

        应该有帮助。

        【讨论】:

        • 我写道:gem uninstall rails -v 4.0.0.beta1 ( gem uninstall rails -v=4.0.0.beta1)
        【解决方案7】:

        首先你应该了解rails的位置。 输入您的控制台(bash、zsh 等)

        which rails
        

        如果它位于您的主文件夹中,例如:

        /home/your_name/.rvm/gems/ruby-1.9.3-p392/bin/rails
        

        然后,您应该使用本地 gem 将其删除:

        gem uninstall rails
        

        否则,你可能不得不使用sudo

        sudo gem uninstall rails
        

        注意:您可以按以下方式检查您的 Rails 版本:

        本地:

        gem list rails 
        

        全球:

        sudo gem list rails 
        

        【讨论】:

          【解决方案8】:

          我还必须卸载 Railties,一切正常。

          【讨论】:

            【解决方案9】:

            您只需尝试此命令。它将有助于卸载所有导轨 “宝石卸载 railties” 我认为这是完全卸载所有 rails 的唯一方法

            【讨论】:

              猜你喜欢
              • 2016-08-09
              • 2015-12-26
              • 2017-10-03
              • 2014-01-20
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2020-12-02
              • 2017-11-25
              相关资源
              最近更新 更多