---
title: "Write permission error when installing gems"
date: "2015-05-01"
category: "ruby"
slug: "write-permission-error-when-installing-gems"
---

## Symptom

On [[determining-platform-version]] with multiple Ruby interpreter support, installing a gem fails with a permission error:

 [user@sol ~]$ gem install --no-rdoc --no-ri passenger rails
 Fetching: passenger-5.0.6.gem (100%)
 ERROR: While executing gem ... (Gem::FilePermissionError)
 You don't have write permissions for the /.socket/ruby/gems/ruby-2.1.2 directory.

## Cause

The `GEM_HOME` environment variable is not configured until `rvm use` is run. Without it, Rubygems attempts to install to the system default directory, which is read-only.

## Solution

Select a Ruby version with `rvm use` before installing gems. This initializes the rvm shim and sets `GEM_HOME` to your user directory:

cd /var/www
# rvm shim is installed under /var/www
rvm use 2.2.2
# rvm will confirm this version is selected
gem install --no-rdoc --no-ri rails
# Rails installs now without incident

See [[changing-ruby-versions]] for more details.
