PREFIX enviroment variable pollutes gem search path

Steve Wills swills at FreeBSD.org
Tue Jan 3 22:25:35 UTC 2017


Hi,

On 01/03/2017 16:39, José G. Juanino wrote:
> 
> Hello Steve, thanks for time and patience.

Likewise. :)

> 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.

Right, this is all as I would expect. It's looking in the directory you
specified, which happens to not exist.

> Excuse my poor english, sorry for the misunderstoods.

I think your English is fine, my understanding maybe is not so great.

Steve

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 632 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-ruby/attachments/20170103/fb76dfef/attachment.sig>


More information about the freebsd-ruby mailing list