rbenv-communal-gems icon indicating copy to clipboard operation
rbenv-communal-gems copied to clipboard

Installing via homebrew breaks communal-gem-home command

Open alexbuijs opened this issue 8 years ago • 3 comments

When installed via homebrew, running rbenv communal-gem-home gives the following error:

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

Because homebrew uses symlinks, the cachedir is set to "${BASH_SOURCE%/*}/../version_cache", which evaluates to /usr/local/bin/../version_cache. To fix this, I replaced this line https://github.com/tpope/rbenv-communal-gems/blob/master/bin/rbenv-communal-gem-home#L14 with:

cachedir=$(dirname `php -r "echo realpath(\"$BASH_SOURCE\");"`)/../version_cache

alexbuijs avatar Jun 25 '17 12:06 alexbuijs

I have the same problem, I brew install rbenv-communal-gems and got:

$ bundle --version
mkdir: /usr/local/bin/../version_cache: Permission denied
/usr/local/bin/rbenv-communal-gem-home: line 21: /usr/local/bin/../version_cache/2.4.2: No such file or directory
Bundler version 1.15.4

Even using readlink or realpath gives a pretty undesirable path within the homebrew keg's bin directory:

/usr/local/Cellar/rbenv-communal-gems/1.0.1/bin/rbenv-communal-gem-home/../version_cache

I prefer to use a directory within $RBENV_ROOT, which seems like the right place to be keeping mutable state:

cachedir="$RBENV_ROOT/.communal-gem-version-cache"

Which gives, for me:

/usr/local/rbenv/.communal-gems-version-cache

Or, for per-user:

/Users/sj26/.rbenv/.communal-gems-version-cache

Seems easier than trying to figure out xdg cache directories or something, too.

sj26 avatar Oct 25 '17 06:10 sj26

I can confirm this error with the plugin installed from homebrew.

thegcat avatar Oct 27 '17 13:10 thegcat

Rbenv ships with it's own realpath we could use. I agree, the cache location is weird. I don't remember why I did it that way.

tpope avatar Jan 25 '18 22:01 tpope