Rvm Install For Mac

Step 2 - Load RVM into the Shell. Give that a few seconds to install, and next, we need to make RVM available to the shell. We'll do this by updating our /.bashprofile file. Cd / sudo vim.bashprofile. Note that we're using Vim to update this file, which can be a bit confusing at first. Feel free to open this file in any code editor your. Install Homebrew (Optional) When you try to install a Ruby version it will attempt to install Macports. In my opinion Homebrew is better. If Homebrew is installed before you attempt to install a ruby version with RVM then it will skip the Macports install. Install Homebrew on Mac OS. Rvm install 1.9.3 rvm use 1.9.3 rvm gemset create rails313 rvm use [email protected] 下面进入到项目目录,建立一个.rvmrc 文件。 在这个文件里可以很简单的加一个命令: rvm use [email protected] 然后无论你当前 Ruby 设置是什么,cd 到这个项目的时候,RVM 会帮你加载 Ruby 1.9.3 和 rails313 gemset.

Before you can deploy your app on the production server, you need to install Ruby. In this tutorial we recommend that you use Ruby Version Manager (RVM) for this purpose. RVM is a tool for installing and managing multiple Ruby versions.

This will take about 30 minutes. We will be setting up a Ruby on Rails development environment on macOS 10.14 Mojave. Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. $ rvm install ruby $ rvm -default use ruby. To install a specific version of Ruby, run: $ rvm install ruby-X.X.X $ rvm -default use ruby-X.X.X. Replace X.X.X with the Ruby version you want. Install Bundler. Bundler is a popular tool for managing application gem dependencies. We will use Bundler in this tutorial, so let us install it.

There are other ways to install Ruby, e.g. through yum, apt-get, source tarball, rbenv and chruby. You can use one of those other installation methods if you so wish, and this tutorial will work fine even if you installed Ruby using one of those other installation methods. But the one that we recommend in this tutorial is RVM, because in our opinion it is the easiest option.

Rvm Install For Mac

If you have already installed Ruby, then you can skip to the next page.

Prepare the system

Ensure that curl and gpg are installed, as well as a compiler toolchain. Curl and gpg are needed for further installation steps, while the compiler toolchain is needed for installing common Ruby gems.

Debian, Ubuntu
Red Hat, CentOS, Fedora, Amazon Linux, Scientific Linux
macOS You don't have to do anything. They are already installed.

Install RVM

Run the following commands on your production server to install RVM:

You may need to use gpg2 instead of gpg on some systems.

On systems where sudo is configured with secure_path, the shell environment needs to be modified to set rvmsudo_secure_path=1. secure_path is set on most Linux systems, but not on macOS. The following command tries to autodetect whether it is necessary to install rvmsudo_secure_path=1, and only installs the environment variable if it is the code.

When you are done with all this, relogin to your server to activate RVM. This is important: if you don't relogin, RVM doesn't work. Also if you use gnu screen or another terminal multiplexer, RVM also won't work; you must use a plain ssh session.

Install the Ruby version you want

Usually, installing the latest Ruby version will suffice. If you are deploying the example app from the quickstart, then that example application works with all Ruby versions.

However, if you are deploying your own app, then your app may have a specific Ruby version requirement.

To install the latest version of Ruby, run:

To install a specific version of Ruby, run:

Replace X.X.X with the Ruby version you want.

Install Bundler

Bundler is a popular tool for managing application gem dependencies. We will use Bundler in this tutorial, so let us install it:

For mac password. This option resets your keychain, so you'll need to supply passwords for various services, such as Mail and websites that require usernames and passwords. Click the Create New Keychain button. The last option is not to do anything with the keychain system.

Optional: install Node.js if you're using Rails


If you are using Rails, then you must install Node.js. This is because Rails's asset pipeline compiler requires a Javascript runtime. The Node.js version does not matter.

If you do not use Rails then you can skip to the next step.

To install Node.js:

Debian >= 7 (Wheezy or later)

Run the following commands to install Node.js from the NodeSource APT repository.

Red Hat, CentOS, Fedora, Amazon Linux, Scientific Linux
Other operating systems Please install Node.js from www.nodejs.org.

Heads-up: sudo vs rvmsudo

One thing you should be aware of when using RVM, is that you should use rvmsudo instead of sudo when executing Ruby-related commands. This is because RVM works by manipulating environment variables. However, sudo nukes all environment variables for security reasons, which intereferes with RVM.

Next step

Congratulations, you have installed Ruby on your production server!

Continue: Install Passenger »

This article explains why you should avoid using the version of Ruby bundled with Mac OS X and should instead install your own version of Ruby with RVM, the Ruby Version Manager.

Hands Off the System Ruby

Apple bundles the Ruby programming language with OS X. However, the main caveat for using the bundled version, called the system Ruby, is that Apple bundles Ruby for it’s own use. Therefore, it’s best not to make changes to the system Ruby.

You’ll know when you’re about to change the system Ruby when you need to prefix a gem installation with sudo, for example:

Another reason for not using the system Ruby is that it’s often several versions behind the latest stable version.

The Ruby Version Manager

A better alternative to using the system Ruby is to install Ruby with RVM, the Ruby Version Manager. RVM is a tool for installing different versions of Ruby itself. RVM has the following advantages:

  1. RVM enables you to install multiple versions of Ruby and allows you to change which version you want to use.
  2. RVM installs each version of Ruby in a hidden folder in your home folder so each version of Ruby you install doesn’t affect the system Ruby.
  3. Gems installed by RVM-managed versions of Ruby are installed within the hidden folder in your home folder containing that version of Ruby.
  4. You won’t need use sudo to install gems.

To check that you’re currently using the system Ruby, open Terminal and type the following:

If you’re using the system Ruby, OS X will respond with:

You can check which version of Ruby OS X is using with:

Installing RVM and Ruby

The RVM install page has comprehensive instructions for installing RVM that work on Mac OS X. I’ll provide the steps I used here.

The first step is to install the mpapis public key. However, as the install page notes, you might need gpg. Mac OS X doesn’t ship with gpg so before installing the public key, you’ll need to install gpg. I installed gpg with Homebrew:

After you’ve installed gpg, you can install the mpapis public key:

I've listed the mapis public key install command here for illustration. You should use the version on the RVM install page.

I chose to install RVM with the latest stable version of Ruby, which at the time was 2.2.0:

After the installation completes, close the Terminal window and open a new one to make sure that Terminal picks up any environment changes.

Rvm Install Rails Mac

Using RVM

You can list the versions of Ruby available to RVM with rvm list:

The rvm use command selects a version of Ruby:

You can check that you’re using an RVM-managed version of Ruby with:

OS X now responds with:

which tells us we’re using version 2.2.0 and that version 2.2.0 has been installed in my home folder away from the system Ruby. You can confirm this by asking Ruby itself with:

The RVM-managed version of Ruby responds with:

As I mentioned earlier, gems installed with RVM-managed versions of Ruby are located with the Ruby. You can check where gems will be installed with:

The following lines of output shows that gems will be installed in the folder XXX.

Install Ruby Mac

To find out where a particular gem is installed, use the gem which command. For example, gem which jekyll locates the Jekyll gem:

Comments are closed.