2012-03-30 486 views
4

我和我已經安裝了rbenv並可以運行ruby -v瑞安的RailsCast集339一起以下。我離開我的會議,當我試圖從root回來(通過su deployer,我得到這個錯誤rbenv:權限拒絕

/home/deployer/.rbenv/bin/rbenv: line 20: cd: /root: Permission denied 

這裏是rbenv文件:

#!/usr/bin/env bash 
set -e 
[ -n "$RBENV_DEBUG" ] && set -x 

resolve_link() { 
    $(type -p greadlink readlink | head -1) "$1" 
} 

abs_dirname() { 
    local cwd="$(pwd)" 
    local path="$1" 

    while [ -n "$path" ]; do 
    cd "${path%/*}" 
    local name="${path##*/}" 
    path="$(resolve_link "$name" || true)" 
    done 

    pwd 
    cd "$cwd" 
} 

if [ -z "${RBENV_ROOT}" ]; then 
    RBENV_ROOT="${HOME}/.rbenv" 
else 
    RBENV_ROOT="${RBENV_ROOT%/}" 
fi 
export RBENV_ROOT 

if [ -z "${RBENV_DIR}" ]; then 
    RBENV_DIR="$(pwd)" 
else 
    cd "$RBENV_DIR" 2>/dev/null || { 
    echo "rbenv: cannot change working directory to \`$RBENV_DIR'" 
    exit 1 
    } >&2 
    RBENV_DIR="$(pwd)" 
    cd "$OLDPWD" 
fi 
export RBENV_DIR 


shopt -s nullglob 

bin_path="$(abs_dirname "$0")" 
for plugin_bin in "${RBENV_ROOT}/plugins/"*/bin; do 
    bin_path="${bin_path}:${plugin_bin}" 
done 
export PATH="${bin_path}:${PATH}" 

hook_path="${RBENV_HOOK_PATH}:${RBENV_ROOT}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks" 
for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do 
    hook_path="${hook_path}:${plugin_hook}" 
done 
export RBENV_HOOK_PATH="$hook_path" 

shopt -u nullglob 


command="$1" 
case "$command" in 
"" | "-h" | "--help") 
    echo -e "rbenv 0.3.0\n$(rbenv-help)" >&2 
    ;; 
*) 
    command_path="$(command -v "rbenv-$command" || true)" 
    if [ -z "$command_path" ]; then 
    echo "rbenv: no such command \`$command'" >&2 
    exit 1 
    fi 

    shift 1 
    exec "$command_path" "[email protected]" 
    ;; 
esac 

線20 cd "$cwd"

爲什麼當我試圖回來到一個會議上,我得到這個錯誤任何想法?

+6

當您將用戶切換到「部署者」時,您似乎處於/ root目錄中。請確保您位於「部署者」可以訪問的目錄中。 – d11wtq 2012-03-30 23:41:23

+0

你說得對。我是在'/ root',我認爲部署將有機會獲得,因爲部署是管理小組。你雖然權,目錄的簡單的開關讓我'su'正確。如果你想把這個作爲答案,我會接受它。謝謝。 – 2012-04-03 20:35:52

回答

11

看來,你在/根,當是你將用戶切換到「部署者」。請確保您位於「部署者」可以訪問的目錄中。

值得信賴d11wtq