[Bug 249083] devel/ruby-gems fails to install if /usr/local is a symlink

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 09 Dec 2022 10:59:11 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249083

titus m <titus@edc.ro> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |titus@edc.ro

--- Comment #3 from titus m <titus@edc.ro> ---
if setup.rb is run without --prefix then bindir is taken from ruby config
and then it prepends the destdir
problem is that bindir from config is canonic (with symlinks resolved)
so you end up with a stage dir containing ..../usr/local/stuff
and ..../usr/reallocal/stuff
--- /tmp/Makefile    2022-12-09 12:01:45.050912000 +0200
+++ Makefile    2022-12-09 12:24:40.557735000 +0200
@@ -6,6 +6,8 @@
 DISTNAME=    rubygems-${PORTVERSION}
 DIST_SUBDIR=    ruby

+
+
 MAINTAINER=    ruby@FreeBSD.org
 COMMENT=    Package management framework for the Ruby language
 WWW=        https://rubygems.org/
@@ -72,3 +74,7 @@
     cd ${STAGEDIR}${PREFIX}/ && ${FIND} -ds ${DOC_DIR}/ ! -type d >>
${TMPPLIST}

 .include <bsd.port.mk>
+REAL_PREFIX!=   realpath ${PREFIX}
+.if ${REAL_PREFIX} != ${PREFIX}
+   GEMS_ENV+= GEM_XXX_BIN=${PREFIX}/bin
+.endif

=========================================================
and add this diff file in files/patch-fix-linked-local
Code:
--- lib/rubygems/commands/setup_command.rb.orig    2022-12-09
12:22:16.123948000 +0200
+++ lib/rubygems/commands/setup_command.rb    2022-12-09 12:22:34.331107000
+0200
@@ -448,10 +448,14 @@
   def generate_default_dirs
     prefix = options[:prefix]
     site_or_vendor = options[:site_or_vendor]
+    xxx_bin = ENV["GEM_XXX_BIN"]

     if prefix.empty?
       lib_dir = RbConfig::CONFIG[site_or_vendor]
       bin_dir = RbConfig::CONFIG["bindir"]
+      if xxx_bin && !xxx_bin.empty?
+      bin_dir = xxx_bin
+      end
     else
       lib_dir = File.join prefix, "lib"
       bin_dir = File.join prefix, "bin"

-- 
You are receiving this mail because:
You are the assignee for the bug.