简体   繁体   English

如何完全卸载ruby,rails,rvm,gem?

[英]How do I completely uninstall ruby, rails, rvm, gems?

I am very new to Ruby on Rails. 我是Ruby on Rails的新手。 I have installed ruby, rails, gems, and RVM (and possibly some more RoR-associated files) via Mac OS terminal. 我已经通过Mac OS终端安装了ruby,rails,gem和RVM(可能还有一些与RoR相关的文件)。 When I first installed these softwares, they seemed to work fine, and I could execute command lines like: rails new 'project' or rails server But then I messed around with git, directory, and some sudo bundle/gem commands a little bit because "bundle install" command wouldn't work. 当我第一次安装这些软件时,它们似乎运行良好,并且可以执行以下命令行:rails new'project'或rails server但后来我弄乱了git,目录和一些sudo bundle / gem命令,因为“捆绑安装”命令不起作用。 Honestly, I don't know what I have done, but all of these command lines have stopped working now. 老实说,我不知道自己做了什么,但是所有这些命令行现在都停止了工作。 They output various error messages, such as: 它们输出各种错误消息,例如:

1) There was an error parsing 'Gemfile': Undefined local variable or method for Gemfile. 1)解析'Gemfile'时出错:Gemfile的未定义局部变量或方法。 Bundler cannot continue. 捆绑器无法继续。

2) bash: /usr/local/bin/rails: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory 2)bash:/ usr / local / bin / rails:/ usr / local / opt / ruby​​ / bin / ruby​​:错误的解释器:没有这样的文件或目录

3) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions 3)错误:执行gem时...(Gem :: FilePermissionError)您没有写权限

4) find spec_for exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException) 4)find spec_for exe':找不到gem bundler(> = 0.a)(Gem :: GemNotFoundException)

I think there were more errors, but these are all I can remember for now. 我认为还有更多错误,但是这些我现在都还记得。 Obviously, I am getting some intimidating error messages that I don't understand. 显然,我收到了一些我不理解的可怕的错误消息。

So I have come to a conclusion that I should uninstall all Ruby, Rails, Gems, RVM, and Homebrew files. 因此,我得出的结论是,我应该卸载所有Ruby,Rails,Gems,RVM和Homebrew文件。 But even this task looks very challenging to me. 但是即使这个任务对我来说也非常具有挑战性。 I have tried numerous command lines in an attempt to delete them, but when I type in "rails" on spotlight, I still see lots of rails-associated files. 我尝试了许多命令行以尝试删除它们,但是当我在聚光灯下键入“ rails”时,仍然看到很多与Rails相关的文件。 Also, when I type "ruby -v" on terminal, it is still showing the ruby 2.0.0p648 version. 另外,当我在终端上键入“ ruby​​ -v”时,它仍显示ruby 2.0.0p648版本。

When I type in "which ruby" on terminal, it says "/usr/bin/ruby When I type in "which rails" on terminal, it says "usr/local/bin/rails 当我在终端上输入“哪个红宝石”时,它说“ / usr / bin / ruby​​”当我在终端上键入“哪个红宝石”时,它说“ usr / local / bin / rails”

In short, I just want to delete all of these RoR-related files, softwares, and every trace of them, and reinstall them clean. 简而言之,我只想删除所有与RoR相关的文件,软件以及它们的所有痕迹,然后将它们重新安装干净。 Please please help me. 请帮帮我。 I do not want to give up coding. 我不想放弃编码。 Is it too late to say that I'm sorry? 说对不起现在为时已晚?

#This is my .bash_profile

# Enable tab completion
source ~/.profile

# colors!
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
reset="\[\033[0m\]"

# Change command prompt
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# '\u' adds the name of the current user to the prompt
# '\$(__git_ps1)' adds git-related stuff
# '\W' adds the name of the current directory
export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset"

alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
~                                                                               
"~/.bash_profile" 21L, 720C

Ruby is installed on OS X by default. Ruby默认安装在OS X上。 So you don't want to remove that, there are things that might require ruby that has nothing to do with rails or your rails projects, you should ignore it. 因此,您不想删除它,有些事情可能需要使用ruby与rails或rails项目无关,您应该忽略它。 (and you should probably not use spotlight for finding dev files, its just confusing as to what is safe and what is not to play with) (您可能不应该使用Spotlight来查找开发文件,它只是混淆了什么是安全的以及不应该使用什么)

Secondly, you'll hardly EVER use sudo for any rails-related work on your mac, so if a tutorial wants you to run that command, don't. 其次,您几乎不会在Mac上使用sudo进行任何与Rails相关的工作,因此,如果本教程希望您运行该命令,请不要使用。

And lastly, its possible it's not as bad as you think. 最后,它可能没有您想象的那么糟糕。 So there's 2 steps. 所以有两个步骤。 1 - Fix your rvm environment and 2 - fix your gemfile 1-修复您的rvm环境,2-修复您的gemfile

TO RESOLVE --Start be reinstalling RVM 要解决 --start来重新安装RVM

\curl -sSL https://get.rvm.io | bash

Now because it's changed your shell environment (added variables and aliases) and because you've changed some things that are unpredictable... Log out, and log back into your mac. 现在,因为它更改了您的Shell环境(添加了变量和别名),并且因为您更改了一些不可预测的内容,所以请注销并重新登录到Mac。

** Which ruby is in use now? **现在正在使用哪个红宝石? ** **

which ruby

If you're system is still showing /usr/bin/ruby then you'll need to edit your shell profiles. 如果系统仍然显示/ usr / bin / ruby​​,则需要编辑shell配置文件。 Because I don't know what you might have done, or what shell env you're using I'll just be thorough. 因为我不知道您可能会做些什么,或者您正在使用什么shell env,所以我会做的很透彻。 Any excess won't hurt. 任何多余的东西都不会伤害。

You'll review (in the editor of your choice) 4 hidden files in your home directory 您将(在您选择的编辑器中)查看主目录中的4个隐藏文件

/Users/yourhome/.profile

/Users/yourhome/.bashrc

/Users/yourhome/.zshrc

/Users/yourhome/.bash_profile

If you're using bash, then make sure your bash_profile has in it 如果您使用的是bash,请确保其中包含您的bash_profile

source ~/.profile

In the bashrc nad zshrc files make sure the rvm path exists 在bashrc nad zshrc文件中,确保rvm路径存在

export PATH="$PATH:$HOME/.rvm/bin" export PATH =“ $ PATH:$ HOME / .rvm / bin”

In the .profile file make sure this command exists 在.profile文件中,确保此命令存在

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

-- Once you've saved your changes, log out and back in (you shouldn't have have to do this but again, just being thorough). -保存更改后,注销并重新登录(您不必这样做,但再次进行,只是要彻底)。

Once that is done, you should be able to install a ruby - 完成后,您应该可以安装红宝石-

rvm install ruby-2.2.3

Now if you say rvm use ruby-2.2.3 and then which ruby, you should see a pointer to your home directory where rvm lives. 现在,如果您说rvm使用ruby-2.2.3,然后使用哪个ruby,您应该会看到一个指向rvm所在的主目录的指针。


* Now to fix the Gemfile * You have an encoding problem, which is what caused you the errors that made you see spots in the first place. *现在修复Gemfile *您有一个编码问题,这就是导致您出现错误的原因,这些错误使您首先看到斑点。 If you paste the contents of the file here 如果您将文件内容粘贴到此处

(in a terminal in the directory of your rails project) (在rails项目目录的终端中)

cat Gemfile 猫Gemfile

Paste those contents here and it can be fixed. 将这些内容粘贴到此处即可修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM