3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rails -v を行った際の Permission denied

Posted at

macos
自分用のメモです

/usr/local/bin/rbenv-communal-gem-home を確認

mkdir: /usr/local/bin/../version_cache: Permission denied
/usr/local/bin/rbenv-communal-gem-home: line 21: /usr/local/bin/../version_cache/2.6.3: No such file or directory

となっていたので、rbenv-communal-gem-home をエディタに表示して確認してみる

$ open /usr/local/bin
# usr/local/binディレクトリをオープン
rbenv-communal-gem-home.
if [ "$1" = "--complete" ]; then
  exec rbenv-versions --bare
fi

rbenv_version="${1:-$(rbenv-version-name)}"
if [ -L "$RBENV_ROOT/versions/$rbenv_version/lib/ruby/gems" ]; then
  cachedir="${BASH_SOURCE%/*}/../version_cache"
  cachefile="$cachedir/$rbenv_version"
  if [ -f "$cachefile" ]; then
    communal_version="$(cat $cachefile)"
  else
    mkdir -p "$cachedir"
    communal_version="$("$RBENV_ROOT/versions/$rbenv_version/bin/ruby" -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')"
    echo "$communal_version" > "$cachefile"
  fi

  echo "$RBENV_ROOT/gems/$communal_version"
else
  exit 1
fi

こうなってた。すなわち

mkdir: /usr/local/bin/../version_cache: Permission denied

は、 mkdir -p "$cachedir" でディレクトリ作りたいけど、このgemにはその権限がない。だと思う。

/usr/local/bin/../version_cache/2.6.3: No such file or directory

は、 echo "$communal_version" > "$cachefile" の際に cachefileが存在しないために出てきたエラーだと思う。(cachedirが存在しない、作成できなかったため)

cachefileのパスに含まれているcachedirを有効にする

# cachedir="${BASH_SOURCE%/*}/../version_cache" を消して
cachedir="${BASH_SOURCE%/*}/../Cellar/rbenv-communal-gems/1.0.1_1/version_cache"
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?