From: Josh Cheek Date: 2010-01-31T15:00:57+09:00 Subject: Re: "require 'rubygems'" In Your Library/App/Tests Is Wrong? --000e0cd1070a862f3b047e6f976f Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Sat, Jan 30, 2010 at 1:05 PM, Xavier Noria wrote: > On Sat, Jan 30, 2010 at 7:21 PM, Josh Cheek wrote: > > If they installed your gem using rubygems they will load rubygems. > They can't load your library otherwise in the first place. Executables > may be a different story. > > The way dependencies are available in your client's machine is not > your business! I gave several examples where rubygems may not be > available at runtime. > On Sat, Jan 30, 2010 at 1:31 PM, Intransition wrote: > > > Perhaps a compromise? If I am working on some gem that uses mechanize,= I > > could require it like this: > > > > def require_gem( gem_name ) > > begin > > require gem_name > > rescue LoadError > > require( begin GEM_MANAGER rescue 'rubygems' end ) > > require gem_name > > end > > end > > You should simply not have to use require 'rubygems' in your code at > all. > > Perhaps I am confused, is there a problem with this code?: begin require 'mechanize' rescue LoadError require 'rubygems' require 'mechanize' end From here, it appears that if you have your own way of managing gems, then rubygems will not be loaded, because you will not experience a LoadError. Thus it satisfies that I don't tell you how to load your gems, while for th= e vast majority of people, it simply works the way they want / expect it to. If this is not acceptable, please be explicit in explaining why (perhaps an example of how it would require rubygems if you are using a different manager). If it is acceptable, but my code earlier is not, please explain the difference. If it is acceptable, and my code earlier is, then perhaps Ruby should behav= e this way by default, since it would make life easier for both rubygems user= s (because they don't have to tell their code to require rubygems) and non-rubygems users (because the gems they get will not have required rubygems). In this case, the language would encourage the proper behaviour, because there would be no need to require rubygems (and thus no hurdles for people who do not want it loaded). On Sat, Jan 30, 2010 at 2:32 PM, Shot (Piotr Szotkowski) wrote= : > Josh Cheek: > > > I wonder how many people _don't_ use rubygems. What creates more work, > > requiring rubygems so that people who don't want it don't have to use > > it, or not requiring rubygems so that people who do want it have to > > keep putting -rubygems when they load files? > > Ruby 1.9 has RubyGems built-in, and for the legacy version you can > simply add -rubygems to your RUBY_OPTS and be done with the problem. > > =97 Shot > > I don't have 1.9, but this sounds like it requires rubygems automatically, which seems to contradict what several people earlier have said we should do. For example, the original post quotes "The system I use to manage my $LOAD_PATH is not your library/app/tests concern." If I understand what you have said, it sounds like the language has done what they are saying that w= e should not do. --000e0cd1070a862f3b047e6f976f--