Issue #6124 has been updated by naruse (Yui NARUSE).


nobu (Nobuyoshi Nakada) wrote:
> Sorry for close without the description.
> 
> The default gem just shows the bundled libraries as also gems, not avoid to install them as-is.
> The --disable=gem option does not have any effect on standard libraries.
> 
> @nahi, just keep in your bookmark.

nobu's explanation is still too short, so I additional to say,


> ruby -rjson -e "puts JSON::VERSION"
> 1.5.4

Strictly speaking, Vit's example showed in [ruby-core:43126] is not an issue of fake gem.
This is mainly because of the behavior of rubygems itself and require.

See following examples:

% ruby -rjson -e'puts JSON::VERSION'
1.5.4
% ruby -e'require"json";puts JSON::VERSION'
1.5.4
% ruby -e'gem"json";require"json";puts JSON::VERSION'
1.7.3

As they show, you can load gem's json if and only if call gem "json".
So what you want to do is already you can,
and if you want to write this shorter, it is another issue.
----------------------------------------
Bug #6124: What is the purpose of "fake" gems in Ruby
https://bugs.ruby-lang.org/issues/6124#change-27227

Author: vo.x (Vit Ondruch)
Status: Closed
Priority: Normal
Assignee: nahi (Hiroshi Nakamura)
Category: 
Target version: 
ruby -v: ruby 1.9.3p0 (2011-10-30) [x86_64-linux]


As I tried to point out in #6123, the "fake" gems which are distributed with Ruby breaks user's expectations. The following example should fail:

$ ruby --disable-gems -e "puts require('bigdecimal')"
true

However, it is not failing. Could you please enlighten me what is the purpose of fake gem then? Even if you install updated BigDecimal from rubygems.org, the bundled version will won unless you use "gem 'bidgecimal'" somewhere in the code. This makes no sense.

Don't take me wrong, I am big fan of gemified stdlib #5481, however this is not the way how it should be done.


-- 
http://bugs.ruby-lang.org/