简体   繁体   中英

How do I completely uninstall ruby, rails, rvm, gems?

I am very new to Ruby on Rails. I have installed ruby, rails, gems, and RVM (and possibly some more RoR-associated files) via Mac OS terminal. 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. 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. Bundler cannot continue.

2) bash: /usr/local/bin/rails: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory

3) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions

4) find spec_for exe': can't find 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. 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. Also, when I type "ruby -v" on terminal, it is still showing the ruby 2.0.0p648 version.

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

In short, I just want to delete all of these RoR-related files, softwares, and every trace of them, and reinstall them clean. 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. 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. (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)

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.

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

TO RESOLVE --Start be reinstalling 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.

** 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. Because I don't know what you might have done, or what shell env you're using I'll just be thorough. Any excess won't hurt.

You'll review (in the editor of your choice) 4 hidden files in your home directory

/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

source ~/.profile

In the bashrc nad zshrc files make sure the rvm path exists

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

In the .profile file make sure this command exists

[[ -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.


* 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. If you paste the contents of the file here

(in a terminal in the directory of your rails project)

cat Gemfile

Paste those contents here and it can be fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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