简体   繁体   中英

Understanding Ruby environment (rvm, rails, gems, etc…)

I'm not a Ruby developer, but I need to run an application that use Ruby on rails with a lot of gems on a Mac.

Following few tutorials online I see that I need to install plenty of apps like xCode, Passenger, RVM, ecc...

Everything is ok but what about if one day I decide to uninstall everything keeping only the Ruby default installation that already exist in a Mac?

Where can I localize all the gems that I download using bundle install ?

Using the Terminal and writing all these commands is a clean solution or it make my system "dirty" and slow?

Sorry for all these question, but I would like to know if there is a "best practice" to install this environment, how it work and how to uninstall it completely if I decide to do that one day.

RVM will provide you what you wanted. It will keep the system Ruby safe and install localized Ruby and rubygems. From rvm you can install/uninstall any version of ruby anytime and that won't affect the system ruby. When one day you wanted to remove all ruby except system one, first remove them using RVM, then then remove rvm itself.

Install RVM from here: https://rvm.io/rvm/install/

Installing RVM will install ruby a ruby. If you want, you can install other version. If you want to remove you simply run rvm remove ruby-1.9.3-p194

you can get exact ruby version using rvm list

localized gemsets

you will need an .rvmrc file.

To create .rvmrc , enter the project directory and run the following command: rvm --create --rvmrc ruby-1.9.3-p194@myproject

Then re-enter the directory and it will ask you to trust the .rvmrv file and you got to trust it. now if you run the bundle install it will install localized gemsets in your gemset directory (most possibly in your ~ path).

Note: please make sure ruby-1.9.3-p194 matches the name exactly that you found in rvm list

RVM is what you need. All things could be done in command line and it will be clean and ready to be removed at any time.

Xcode is not necessary. But brew may be. If you have brew, install apple-gcc42 first. The llvm-gcc with Xcode 4.2 and later works not very well for compiling ruby.

Then install rvm. It is easy by following the steps on rvm official site. After installing it, try rvm requirements first. This command will tell you what you need to build ruby. Some libs may not are on the machine, like readline etc.

When all requirements are met, rvm install 1.9.3 will install ruby 1.9.3 on your machine and it takes several minutes. You can install any ruby version in rvm list known . And rvm list will show you local versions.

Use rvm default some_version to set default one. This will not be any conflict with system installation. And rvm use some_version will change ruby version to a specific one.

All things rvm installed will be kept in ~/.rvm/ by default, including gems.

There should be no need to uninstall rvm. But it is easy to do this by removing it directly.

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