summaryrefslogtreecommitdiff
path: root/gem_prelude.rb
Commit message (Collapse)AuthorAgeFilesLines
* Removed needless .rbHiroshi SHIBATA2020-12-021-1/+1
|
* Emit warning when 'RubyGems' were not properly loaded.Vít Ondruch2020-12-021-0/+1
|
* Emit warning when 'did_you_mean' was not properly loaded.Vít Ondruch2020-12-021-0/+1
|
* Don't fail when 'RubyGems' are not available.Vít Ondruch2020-12-021-1/+4
| | | | | | Although 'RubyGems' are always available in upstream Ruby, it might not be available optionally when Ruby is delivered via packaging systems. E.g. Linux distributions.
* Don't fail when 'did_you_mean' is not available.Vít Ondruch2020-12-021-1/+5
| | | | | | | | | | Although 'did_you_mean' is always available in upstream Ruby, it might not be available when speed, memory, disk or network bandwidth is a concern. This is typically the case for production environment, where 'did_you_mean' is of limited usage. Also it might not be available optionally when Ruby is delivered via packaging systems. E.g. Linux distributions.
* Do not call 'gem "did_you_mean"' for nowYuki Nishijima2019-11-301-8/+2
| | | | | | | | | | | | | | This will slow down the time that the +require+ method takes to load DYM, but this has caused a build failure in a certain situation: https://ci.appveyor.com/project/ruby/ruby/builds/29214253/job/r9u9c8p95tnlftt3#L24965 which is reported as a separate bug: https://bugs.ruby-lang.org/issues/16382?next_issue_id=16381 For now this commit should fix the builds, but we should come back and add back the 'gem' call.
* Reduce system calls by activating the `did_you_mean` gem.tenderlove2016-02-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Activating the gem puts the gem on the load path, where simply requiring the file will search every gem that's installed until it can find a gem that contains the `did_you_mean` file. Calling RubyGems' `require` will search each installed gem until it can find one that contains the file it should require. This means that the more gems you have installed, the longer it can take to require that gem. To see this in action, lets compare the number of `stat` calls for a "bare require" vs the number of `stat` calls for a require that follows a gem activation by using these two programs: ``` [aaron@TC rubygems (master)]$ cat req_dym.rb begin require 'did_you_mean' rescue LoadError end [aaron@TC rubygems (master)]$ cat gem_dym.rb begin gem 'did_you_mean' require 'did_you_mean' rescue Gem::LoadError, LoadError end ``` The first program just requires the `did_you_mean` gem, where the second one activates the gem, then requires it. We can count the number of `stat` calls using `dtrace`: ``` [aaron@TC rubygems (master)]$ ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15] [aaron@TC rubygems (master)]$ sudo dtrace -q -n 'syscall::stat*:entry { printf("%s\n", copyinstr(arg0)); }' -c`rbenv which ruby`" --disable-did_you_mean req_dym.rb" | wc -l dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 283 [aaron@TC rubygems (master)]$ sudo dtrace -q -n 'syscall::stat*:entry { printf("%s\n", copyinstr(arg0)); }' -c`rbenv which ruby`" --disable-did_you_mean gem_dym.rb" | wc -l dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 13 ``` The "bare require" version does over 10x the number of stat calls compared to the "gem, then require" version. Of course the number for the first one depends on the number of gems you have installed that sort before the `did_you_mean` gem. Lets also look at trunk Ruby: ``` [aaron@TC rubygems (master)]$ ruby -v ruby 2.4.0dev (2016-02-25 trunk 53940) [x86_64-darwin15] [aaron@TC rubygems (master)]$ sudo dtrace -q -n 'syscall::stat*:entry { printf("%s\n", copyinstr(arg0)); }' -c`rbenv which ruby`" --disable-did_you_mean req_dym.rb" | wc -l dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 2325 [aaron@TC rubygems (master)]$ sudo dtrace -q -n 'syscall::stat*:entry { printf("%s\n", copyinstr(arg0)); }' -c`rbenv which ruby`" --disable-did_you_mean gem_dym.rb" | wc -l dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 dtrace: error on enabled probe ID 3 (ID 826: syscall::stat64:entry): invalid user access in action #1 at DIF offset 24 685 ``` This change will reduce the number of `stat` calls on trunk Ruby too, but since this installation doesn't have the `did_you_mean` gem, RubyGems is still reading every gem spec file so that it can raise a `Gem::LoadError` exception with a nice error message. If we can modify RubyGems a little, it may be possible to drop the number of stat calls even on a Ruby installation that doesn't have the `did_you_mean` gem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c (usage, enable_option, disable_option, process_options): newusa2015-09-091-1/+7
| | | | | | | | | option `--disable_did_you_mean`. * gem_prelude.rb: now requires did_you_mean gem by default if available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c (process_options): revert r30549.nobu2011-01-171-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c (process_options): autoload rubygems.nobu2011-01-151-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c (ruby_init_prelude): get rid of global namespacenobu2011-01-151-1/+1
| | | | | | pullution. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reduced gem_prelude to just require rubygems. Reviewed by Evan Phoenixryan2011-01-141-239/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Tue Aug 17 07:38:43 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>nobu2010-08-161-1/+1
| | | | | | | * gem_prelude.rb, lib/rubygems.rb (Gem.suffixes): include empty suffix. [ruby-core:31730] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb, lib/rubygems.rb (Gem.suffixes): return truelynobu2010-08-081-0/+4
| | | | | | require-able suffixes only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Load gems properly. Fixes [ruby-core:31377]evan2010-07-211-5/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Pull rubygem's custom require into gem_preludeevan2010-07-201-97/+15
| | | | | | | | This solves the gem loading issue by never touching $LOAD_PATH in gem_prelude and instead loading all of rubygems more quickly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb: provide workaround for gem activation. Currently,mame2010-07-071-10/+14
| | | | | | | | | | gem activation does not work by default. Now it can be worked around by requiring "rubygems" first. [ruby-core:29486] a patch from Evan Phoenix in [ruby-core:31096]. * lib/rubygems.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r28200.naruse2010-06-101-17/+103
| | | | | | | It caused many failures on test-all and following is SEGV. ./ruby -e 'require %!#{"foo/" * 10000}foo!' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb: load full rubygems at LoadError for activationnobu2010-06-071-103/+17
| | | | | | | check. [ruby-core:29486] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem::QuickLoader.load_full_rubygems_library):nobu2010-04-231-1/+1
| | | | | | suppress a warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem::QuickLoader.load_full_rubygems_library):nobu2010-04-231-7/+3
| | | | | | | | get rid of creating same regexps many times. * lib/rubygems/custom_require.rb (Kernel#require): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c (ruby_init_loadpath_safe): mark initial load paths.nobu2010-03-121-1/+1
| | | | | | | | | | * gem_prelude.rb (push_all_highest_version_gems_on_load_path): search insertion position by initial load path mark. * lib/rubygems.rb (Gem.load_path_insert_index): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (push_all_highest_version_gems_on_load_path):nobu2009-12-301-12/+4
| | | | | | | simplified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Kernel#gem): should make gem private. a patchmatz2009-12-191-1/+1
| | | | | | from Sho Hashimoto in [ruby-dev:39838]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem.set_home): must dup before force_encodingnaruse2009-11-261-2/+3
| | | | | | | and must force_encoding before gsub. cf. Yen Sign problem of SJIS [ruby-core:26910] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem.user_home): force_encoding(naruse2009-11-051-1/+1
| | | | | | Encoding.find('filesystem')). [ruby-core:26525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (get_filesystem_encoding): removed.naruse2009-10-281-2/+2
| | | | | | | | | | | | | | | | | * encoding.c (rb_locale_encindex): added. * encoding.c (rb_filesystem_encindex): added. * encoding.c (rb_filesystem_encindex): add an alias 'filesystem'. [ruby-dev:39574] * encoding.c (enc_find): add rdoc about special aliases. * gem_prelude.rb (Gem.set_home): use Encoding.find('filesystem'). * gem_prelude.rb (Gem.set_paths): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem.set_home):naruse2009-10-281-1/+2
| | | | | | | | | force_encoding(Encoding.filesystem_encoding) [ruby-dev:39546] * gem_prelude.rb (Gem.set_paths): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem.path): uses Gem.default_path as a default valueyugui2009-07-301-1/+11
| | | | | | | | so that ruby finds gems in ~/.gem/. (Gem.user_home): reduced version of lib/rubygems.rb's. Gem.default_path needs it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * tool/compile_prelude.rb: replaces "require" with in-place evaluationyugui2009-07-301-105/+3
| | | | | | | | | | | so that copy & paste for lib/rubygems/default.rb is not necessary. * gem_prelude.rb: removes copied codes from lib/rubygems/defaults.rb. uses require instead. * common.mk (prelude.c): adds dependency for lib/rubygems/defaults.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/purelib.rb: translates a fake path to rubygems in $" intoyugui2009-07-151-5/+28
| | | | | | | | | | | | | | an alternative in $: so that Kernel.#require does not load more rubygems.rb. Resolves many failures in test/rubygems/*. * gem_prelude.rb (Gem.load_full_rubygems_library): supports case the rubygems to load is not in $(rubylibprefix). (Gem.path_to_full_rubygems_library): new method for the changes in purelib.rb and Gem.load_full_rubygems_library. (Gem.fake_rubygems_as_loaded): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.c (Gem.default_dir): follows the change on yugui2009-06-281-7/+10
| | | | | | lib/rubygems/default.rb in r23879 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update to RubyGems 1.3.4 r2223drbrain2009-06-091-50/+76
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem.default_dir and misc.): use rubylibprefix.yugui2009-05-211-8/+4
| | | | | | follows the chagne in r23368. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (Gem::QuickLoader#push_gem_version_on_load_path):nobu2009-04-191-9/+11
| | | | | | | | check for requirement if the gem is installed. a patch from Kyosuke MOROHASHI at [ruby-dev:38020]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Match full RubyGems behavior when a gem can't be founddrbrain2008-12-231-3/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Don't remove methods twice. [bug#555]drbrain2008-12-221-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (enc_get_default_encoding): removed.yugui2008-12-121-0/+4
| | | | | | | | | | | | | | | | | | | | Generalizing rb_default_{external,internal}_encoding seems to be difficult. default_external cannot be NULL even before detected. [ruby-dev:37390] * encoding.c (rb_default_external_encoding): has its own implementation again. * encoding.c (rb_default_internal_encoding): ditto. * gem_prelude.rb: added notice. * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): uses locale encoding but not ASCII-8BIT. * ruby.c (process_options): refers less to default_external. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Don't require rubygems/defaults from gem_prelude.rb.drbrain2008-10-311-7/+104
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* merged r19975 and r19978 from ruby_1_9_1 into trunk.yugui2008-10-281-2/+2
| | | | | | | | | * gem_prelude.rb: considers --program-suffix and prefix configure options. * lib/rubygems/defaults.rb: ditto. * test/rubygems/test_gem.rb (@default_dir_re): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb: disables debug and verbose flags to suppress failurenobu2008-10-261-12/+18
| | | | | | | messages. interpolation does not occur inside single quotes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update to RubyGems 1.3.1 r1909.drbrain2008-10-251-9/+33
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix RubyGems for 1.9, r1780drbrain2008-06-171-55/+47
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c (ruby_init_gems), gem_prelude.rb: check if Gem is definednobu2008-05-121-2/+2
| | | | | | | instead of Gem::Enable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gem_prelude.rb (load_full_rubygems_library, const_missing): preventnobu2008-05-121-2/+8
| | | | | | | infinite recursion. [ruby-dev:34539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Import RubyGems 1.1.0drbrain2008-03-311-161/+168
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Import RubyGems r1601. [ruby-core:15381].drbrain2008-02-101-1/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove methods from Gem, not QuickLoader, to fix warningsdrbrain2007-12-241-2/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use require to load rubygems.rb in gem_prelude.rb so the correct path is in ↵drbrain2007-12-231-5/+13
| | | | | | on RubyGems upgrade. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Place bin dir before lib dir so gem bin stubs work.drbrain2007-12-221-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e