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

Doesn't handle linux distributions that use lib64 instead of lib.

Open nogweii opened this issue 10 years ago • 3 comments

OpenSUSE is an example of such -- lib/ is used for 32-bit libraries & binaries, and compiling Ruby from source will make a 64-bit binary, so it's configured to use lib64/ instead.

nogweii avatar Apr 30 '14 23:04 nogweii

Got a good idea of how to detect this?

On Wed, Apr 30, 2014 at 7:46 PM, No GUI [email protected] wrote:

OpenSUSE is an example of such -- lib/ is used for 32-bit libraries & binaries, and compiling Ruby from source will make a 64-bit binary, so it's configured to use lib64/ instead.

— Reply to this email directly or view it on GitHubhttps://github.com/tpope/rbenv-communal-gems/issues/9 .

tpope avatar May 01 '14 01:05 tpope

There is my commit to rbtrace but that requires loading Ruby, which I don't know how performant it would be. However this is a pretty much guaranteed to never change, so perhaps doing it on the first installation and caching the result?

Ah, and I've installed JRuby which uses lib/ and not lib64. Perhaps then doing that once per installation?

nogweii avatar May 01 '14 18:05 nogweii

Here is a naïve patch that seems to work for me:

diff --git a/bin/rbenv-communal-gem-home b/bin/rbenv-communal-gem-home
index 673ab92..8b2af1c 100755
--- a/bin/rbenv-communal-gem-home
+++ b/bin/rbenv-communal-gem-home
@@ -10,7 +10,7 @@ if [ "$1" = "--complete" ]; then
 fi

 rbenv_version="${1:-$(rbenv-version-name)}"
-if [ -L "$RBENV_ROOT/versions/$rbenv_version/lib/ruby/gems" ]; then
+if [ -L "$RBENV_ROOT/versions/$rbenv_version/lib/ruby/gems" -o -L "$RBENV_ROOT/versions/$rbenv_version/lib64/ruby/gems" ]; then
   cachedir="${BASH_SOURCE%/*}/../version_cache"
   cachefile="$cachedir/$rbenv_version"
   if [ -f "$cachefile" ]; then
diff --git a/bin/rbenv-communize b/bin/rbenv-communize
index 7ffd95b..b2be7ff 100755
--- a/bin/rbenv-communize
+++ b/bin/rbenv-communize
@@ -15,7 +15,11 @@ fi

 communize() {
   local root="$RBENV_ROOT/versions/$1"
-  local gemdir="$root/lib/ruby/gems"
+  local libdir="$root/lib"
+  if [ ! -d "$libdir" ]; then
+    libdir="$root/lib64"
+  fi
+  local gemdir="$libdir/ruby/gems"
   if [ -L "$gemdir" -a -f "$root/etc/gemrc" ]; then
     echo "Gems for $1 are already communal"
   elif [ -d "$gemdir" ]; then
diff --git a/bin/rbenv-sequester b/bin/rbenv-sequester
index 8603b21..ae4d2eb 100755
--- a/bin/rbenv-sequester
+++ b/bin/rbenv-sequester
@@ -15,7 +15,11 @@ fi

 sequester() {
   local root="$RBENV_ROOT/versions/$1"
-  local gemdir="$root/lib/ruby/gems"
+  local libdir="$root/lib"
+  if [ ! -d "$libdir" ]; then
+    libdir="$root/lib64"
+  fi
+  local gemdir="$libdir/ruby/gems"
   if [ -f "$root/etc/gemrc" ] && grep '# added by rbenv communize' "$root/etc/gemrc" >/dev/null; then
     rm "$root/etc/gemrc"
   fi
diff --git a/etc/rbenv.d/install/communal-gems.bash b/etc/rbenv.d/install/communal-gems.bash
index 9b06a99..2682dfa 100644
--- a/etc/rbenv.d/install/communal-gems.bash
+++ b/etc/rbenv.d/install/communal-gems.bash
@@ -4,7 +4,11 @@ if declare -Ff after_install >/dev/null; then
 fi

 sequester_gems() {
-  local gemdir="$PREFIX/lib/ruby/gems"
+  local libdir="$PREFIX/lib"
+  if [ ! -d "$libdir" ]; then
+    libdir="$PREFIX/lib64"
+  fi
+  local gemdir="$libdir/ruby/gems"
   if [ -L "$gemdir" ]; then
     rm "$gemdir"
     mkdir "$gemdir"

nogweii avatar May 01 '14 19:05 nogweii