PREFIX enviroment variable pollutes gem search path

José G. Juanino jjuanino at gmail.com
Tue Jan 3 21:39:33 UTC 2017


El martes 03 de enero a las 20:53:18 CET, Steve Wills escribió:
>
>> But if you run
>> *any* ruby dependent port polluted with PREFIX environment variable, and
>> that port requires some other gem, it will fails at the moment it
>> 'requires' the gem, sure.
>
>Describing it as "polluted" with a PREFIX environment variable seems a
>bit inaccurate to me. PREFIX is a commonly used variable on FreeBSD and
>in this case it's mean to indicate to gem where it might find some
>things. I'm guessing your custom code checks for this variable as well
>and also is meant to use it for something else? Perhaps it could be
>change to use a different variable name?

Hello Steve, thanks for time and patience.

The problem is that if your custom ruby program uses the PREFIX 
environment variable to achieve some other purpose, you must be aware 
that your code will use the assigned value to load the required gems, 
and this is unexpected and will cause a lot of trouble (this reason lead 
to me to say that PREFIX environment variable polluted the search gem 
path).

A contrived example could be, assuming you have installed 
devel/rubygem-test-unit:

$ echo "require 'test/unit'" > prefix_test.rb
$ /usr/local/bin/ruby22 prefix_test.rb
$ echo $?
0
$ PREFIX="some_prefix" /usr/local/bin/ruby22 prefix_test.rb
/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'
        from prefix_test.rb:1:in `<main>'
$ echo $?
1

The error raises because ruby try to find the gem specifications 
directory in the following nonexistent path: 

some_prefix/lib/ruby/gems/2.2/specifications

instead of:

/usr/local/lib/ruby/gems/2.2/gems/specifications

You can check this assertion by running a truss in the failed code, and 
comparing it with the right one.



Excuse my poor english, sorry for the misunderstoods.


-- 
José G. Juanino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-ruby/attachments/20170103/7442a9fd/attachment.sig>


More information about the freebsd-ruby mailing list