我创建了一个项目特定的.rvmrc文件,该文件包括一个自定义gemset(使用命令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

这可以在Mac上使用单用户RVM在本地运行。我们还将Vagrant与Vagrant盒子上的系统级RVM安装在一起使用。但是,当我们将cd放入项目目录并接受.rvmrc文件时,它导致以下消息(是的,有很多重复的错误消息):
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

尝试手动创建gemset时,会提到相同的错误,但同时也提到成功:
$ 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).

我的配置是否有误?如何解决此问题,以便可以使用.rvmrc文件中的自定义gemset?

最佳答案

问题原来是我使用的简单的Chef食谱没有将 Vagrant 添加到rvm组。这可以通过执行以下操作来完成:

sudo usermod -a -G rvm vagrant

但是我决定切换到另一个robust RVM Chef cookbook,它使用以下食谱非常有效:
include_recipe "rvm::system"
include_recipe "rvm::vagrant"

关于ruby - RVM:在系统范围的安装中从.rvmrc文件加载gemset时,权限被拒绝,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9724766/

10-11 07:57