I have created a project specific .rvmrc
file that includes a custom gemset (using the command rvm --rvmrc --create 1.9.2@registration
):
# excerpt of .rvmrc...
environment_id="ruby-1.9.2@registration"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi
This works locally on my Mac, using single-user RVM. We are also using Vagrant with a system-wide RVM install on our Vagrant box. However, when we cd
into the project directory and accept the .rvmrc
file, it results in the following message (yes, there are a lot of duplicate error messages):
mkdir: cannot create directory `/usr/local/rvm/gems/ruby-1.9.2-p318@registration': Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
-bash: /usr/local/rvm/environments/ruby-1.9.2-p318@registration: Permission denied
mkdir: cannot create directory `/usr/local/rvm/wrappers/ruby-1.9.2-p318@registration': Permission denied
Trying to create the gemset manually mentions the same error, but also mentions that it was successful:
$ rvm use 1.9.2
Using /usr/local/rvm/gems/ruby-1.9.2-p318
$ rvm gemset create registration
mkdir: cannot create directory `/usr/local/rvm/gems/ruby-1.9.2-p318@registration': Permission denied
'registration' gemset created (/usr/local/rvm/gems/ruby-1.9.2-p318@registration).
Do I have something configured incorrectly? How can I resolve this issue so I can use a custom gemset from an .rvmrc
file?
The problem turned out to be that the simple Chef recipe I was using was not adding the vagrant user to the rvm
group. This could be accomplished by doing this:
sudo usermod -a -G rvm vagrant
But I decided to switch to a more robust RVM Chef cookbook which worked perfectly using these recipes:
include_recipe "rvm::system"
include_recipe "rvm::vagrant"
Try adding 'sudo'
before your rvm commands
. ruby@registration
will be installed system-wide yet should still work on a per-user basis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With