PREFIX enviroment variable pollutes gem search path

José G. Juanino jjuanino at gmail.com
Tue Jan 3 14:27:55 UTC 2017


El martes 03 de enero a las 01:07:58 CET, José G. Juanino escribió:
>Hi,
>
>I am suffering an annoying issue loading gem libraries; I am not sure 
>if it is FreeBSD specific.
>
>Install some gem, for example rubygem-test-unit-3.1.9, and take a look 
>at the following code:
>
>
>$ ruby22 -r test/unit -e 'puts'
>$ PREFIX=1 ruby22 -r test/unit -ne 'puts'
>/usr/local/lib/ruby/site_ruby/2.2/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- test/unit (LoadError)
>       from /usr/local/lib/ruby/site_ruby/2.2/rubygems/core_ext/kernel_require.rb:55:in `require'
>
>In short: you cannot load any gem if your environment contains the 
>PREFIX variable. When this happens, ruby uses the assigned value 
>instead of /usr/local to search the proper files. This breaks a lot of 
>existent code.
>
>The relevant ports are, installed via pkg:
>
>ruby-2.2.5_1,1
>ruby22-gems-2.6.4
>ruby23-2.3.1_1,1
>
>The FreeBSD version is 11.0-RELEASE.
>
>This issue did not happen in ruby20, I think.

I think that the root issue is this sentence in lang/ruby22 Makefile:

@${RB_SET_CONF_VAR} "prefix" "ENV['PREFIX'] || \3"


It set the following in 
/usr/local/lib/ruby/2.2/amd64-freebsd11/rbconfig.rb:

CONFIG["prefix"] = (ENV['PREFIX'] || TOPDIR || DESTDIR + "/usr/local")

That is wrong, as rbconfig.rb is sourced by gem infraestructure, and 
therefore the result is dependent of your specific environment at 
*runtime*. 

(Please keep me in Cc:, as I am not subscribed to the list).

Regards

-- 
José G. Juanino


More information about the freebsd-ruby mailing list