RoR - 如何删除 Rails 4.1.1 版本? [英] RoR - How to remove Rails 4.1.1 version?

查看:40
本文介绍了RoR - 如何删除 Rails 4.1.1 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 RoR 的新手,我尝试学习 Micheal Hartl 的 Ruby on Rails 教程.在开始本教程之前,我已经提前设置了所有内容并将 Rails 版本更新为 4.1.1 并且一切正常,直到教程中我需要最大 4.0.5 版本的 Rails 才能继续执行示例.为了做到这一点,我尝试了几件事.首先我运行:

I am new to RoR and I tried to follow the Ruby on Rails Tutorial from Micheal Hartl. Before starting the tutorial I already set up everything earlier and updated the Rails version to 4.1.1 and everything worked well until the point in the tutorial where I needed to have max 4.0.5 version of Rails in order to proceed with the example. In order to do so I tried several things. First I run:

gem uninstall rails

之后我收到消息说它已被卸载,但在运行 rails -v 时我仍然有 4.1.1.然后,按照 stackoverflow 上的一个答案,要卸载 railties,我做到了:

after which I received the message that it was uninstalled but when running rails -v I still had 4.1.1. Then,following one answer on stackoverflow, to uninstall railties, I did:

gem uninstall railties 4.1.1

之后在运行时: rails -v 我收到一条消息,表明版本 3.2.18 正在运行,这是我作为 railsinstaller 的一部分安装的版本.不幸的是,在创建一个新应用程序后,它停止了捆绑安装,并且多次没有继续.然后我尝试删除所有 gem,以便从头开始安装所有内容.我是这样做的:

after which when running: rails -v I got a message that version 3.2.18 was running which was the one I installed as part of the railsinstaller. Unfortunately, after creating a new app it stopped on the bundle install and didn't continue, for several times. Then I tried to remove all the gems in order to install everything from scratch. I did it with:

ruby -e "gem list.split(/$/).each { |line| puts gem uninstall -Iax #{line.split(' ')[0]} 除非 line.strip.empty? }"

ruby -e "gem list.split(/$/).each { |line| puts gem uninstall -Iax #{line.split(' ')[0]} unless line.strip.empty? }"

我也在这里找到的.它确实删除了宝石,之后我卸载了 Ruby.然后我用 Rails 版本 3.2.18 的 railsinstaller 再次安装了所有东西.完成后,当我打开 cmd 时,在 Rails 版本下的 Rails 环境配置中,我可以再次看到版本 4.1.1.当我跑:

which I also found here. It did remove the gems, after which I uninstalled Ruby. Then I installed everything again with the railsinstaller which has Rails version 3.2.18. When it finished and when I opened the cmd, in the Rails Environment Configuration under Rails version I could see again version 4.1.1. When i ran:

gem uninstall rails

它卸载了3.2.18版本,正确的.我再次安装了所有东西,希望安装正确的版本并且显示 4.1.1 是一个小错误,但是在创建新应用程序时捆绑程序安装仍然无法正常工作.现在,经过几次尝试,我试图保持原样,不卸载任何东西,而是尝试安装4.0.5版本.首先它安装了 railties 和 rails 4.1.1,然后我得到一个错误:找不到有效的 gem '4.0.5'.

it uninstalled the 3.2.18 version, the correct one. I installed everything again, hoping that the correct version is installed and that showing the 4.1.1 is a minor bug, but the bundler install still didn't work normally when creating a new app. Right now, after several tries, I tried to leave it as is, not to uninstall anything but to try to install the 4.0.5 version besides. First it installed railties and rails 4.1.1 and then I got an error: could not find a valid gem '4.0.5'.

我检查了几个问题和答案,试图设置一整天,但没有成功.我试着写下细节,这样你就可以更好地理解,因为有类似的问题,但没有针对我遇到的完全相同的问题.无论我做了什么,我都完成了许多 gem,版本 4.1.1 仍然在文件夹中.我希望有人知道该怎么做以及如何删除以前的版本 forevr.提前致谢!

I checked for several questions and answers, trying to set it up the whole day but it didn't work out. I tried to write details so you can understand better since there were similar questions but not targeting the exact same problem I have. Whatever I did I finished up with many gems with version 4.1.1 still being in the folders. I hope somebody will know what to do and how to remove the previous version forevr. Thanks in advance!

推荐答案

首先找到 rails gem 目录.

First find the rails gem directory.

有很多方法可以做到,例如查看您的GEM_HOMEGEM_PATH

There are many ways to do it, such as looking in your GEM_HOME and GEM_PATH

echo $GEM_HOME
echo $GEM_PATH

这是一种蛮力方法:

find / -type d -name rails-4.1.1 

这可能会找到多个目录,比如系统的gem目录、cache、docs、bundler目录、RVM或chruby的ruby版本目录等

This may find multiple directories, such as the system's gem directory, cache, docs, bundler directory, ruby versioning directories for RVM or chruby, etc.

如果您是系统的唯一用户,则删除所有这些.

If you're the only user of the system, then remove all of these.

立即验证 4.1.1 是否已消失:

Immediately verify that 4.1.1 is gone:

# Show the executable, if any
which rails  

# Show the version, which should not say 4.1.1
rails --version

# If you're within a bundle directory
bundle exec rails --version

暂时不要捆绑.

编辑您的 Gemfile,它也可能要求 Rails 4.1.1,并设置您想要的确切 Rails 版本:

Edit your Gemfile, which may also be asking for Rails 4.1.1, and set the exact Rails version that you want:

gem 'rails', '= 4.0.5'

现在捆绑:

bundle update

验证 rails 4.1.1 不在您的 Gemfile 中,也不在锁中:

Verify that rails 4.1.1 is not in your Gemfile nor lock:

grep 4.1.1 Gemfile Gemfile.lock

这篇关于RoR - 如何删除 Rails 4.1.1 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆