How do I install Ruby gems when using RVM?

前端 未结 3 1993
忘掉有多难
忘掉有多难 2021-02-01 02:14

I set up RVM and used it to install Ruby and a few other libraries. As I was going through various tutorials and set-ups of other technologies like Rails, I began getting confus

3条回答
  •  迷失自我
    2021-02-01 02:54

    It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.

    Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.

    With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.

    So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.

    So, yep, you're gonna have to run gem install rails, etc.

    Hope that helps clear the confusion.

    (*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.

提交回复
热议问题