6

我创建了一个.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 盒子上使用带有系统范围 RVM 安装的 Vagrant。但是,当我们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?

4

3 回答 3

9

问题原来是我使用的简单 Chef 食谱没有将 vagrant 用户添加到rvm组中。这可以通过这样做来完成:

sudo usermod -a -G rvm vagrant

但我决定改用更强大的 RVM Chef 食谱,它使用这些食谱完美地工作:

include_recipe "rvm::system"
include_recipe "rvm::vagrant"
于 2012-03-15T22:02:41.357 回答
1

尝试'sudo'在您的rvm commands. ruby@registration将在系统范围内安装,但仍应在每个用户的基础上工作。

于 2012-03-15T19:19:06.637 回答
0

对我来说,问题是我在我的主目录(用户安装)中安装了.rvm,但不知何故设法让该目录被root:root chowned。

ls -al /home/darren *drwxr-xr-x 2 root root 4096 Oct 18 16:46 .rvm*

sudo chown darren:rvm .rvm -R

sudo useradd darren rvm

于 2012-10-26T04:01:23.970 回答