* gem_prelude.rb: provide workaround for gem activation. Currently,
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
This commit is contained in:
parent
ce9c952937
commit
d1de97e0bc
@ -1,3 +1,12 @@
|
|||||||
|
Thu Jul 8 00:15:50 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* gem_prelude.rb: provide workaround for gem activation. Currently,
|
||||||
|
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.
|
||||||
|
|
||||||
Wed Jul 7 10:01:34 2010 Adrian Bloomer <adrian.bloomer@gmail.com>
|
Wed Jul 7 10:01:34 2010 Adrian Bloomer <adrian.bloomer@gmail.com>
|
||||||
|
|
||||||
* numeric.c (fix_rev): Replaced fix_rev with '~num | FIXNUM_FLAG'.
|
* numeric.c (fix_rev): Replaced fix_rev with '~num | FIXNUM_FLAG'.
|
||||||
|
@ -136,7 +136,7 @@ if defined?(Gem) then
|
|||||||
|
|
||||||
@loaded_full_rubygems_library = false
|
@loaded_full_rubygems_library = false
|
||||||
|
|
||||||
def self.load_full_rubygems_library
|
def self.remove
|
||||||
return if @loaded_full_rubygems_library
|
return if @loaded_full_rubygems_library
|
||||||
|
|
||||||
@loaded_full_rubygems_library = true
|
@loaded_full_rubygems_library = true
|
||||||
@ -150,6 +150,12 @@ if defined?(Gem) then
|
|||||||
Kernel.module_eval do
|
Kernel.module_eval do
|
||||||
undef_method :gem if method_defined? :gem
|
undef_method :gem if method_defined? :gem
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.load_full_rubygems_library
|
||||||
|
return if @loaded_full_rubygems_library
|
||||||
|
|
||||||
|
remove
|
||||||
|
|
||||||
$".delete path_to_full_rubygems_library
|
$".delete path_to_full_rubygems_library
|
||||||
if $".any? {|path| path.end_with?('/rubygems.rb')}
|
if $".any? {|path| path.end_with?('/rubygems.rb')}
|
||||||
@ -179,6 +185,7 @@ if defined?(Gem) then
|
|||||||
|
|
||||||
GemPaths = {}
|
GemPaths = {}
|
||||||
GemVersions = {}
|
GemVersions = {}
|
||||||
|
GemLoadPaths = []
|
||||||
|
|
||||||
def push_gem_version_on_load_path(gem_name, *version_requirements)
|
def push_gem_version_on_load_path(gem_name, *version_requirements)
|
||||||
if version_requirements.empty?
|
if version_requirements.empty?
|
||||||
@ -241,29 +248,27 @@ if defined?(Gem) then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require_paths = []
|
|
||||||
|
|
||||||
GemPaths.each_value do |path|
|
GemPaths.each_value do |path|
|
||||||
if File.exist?(file = File.join(path, ".require_paths")) then
|
if File.exist?(file = File.join(path, ".require_paths")) then
|
||||||
paths = File.read(file).split.map do |require_path|
|
paths = File.read(file).split.map do |require_path|
|
||||||
File.join path, require_path
|
File.join path, require_path
|
||||||
end
|
end
|
||||||
|
|
||||||
require_paths.concat paths
|
GemLoadPaths.concat paths
|
||||||
else
|
else
|
||||||
require_paths << file if File.exist?(file = File.join(path, "bin"))
|
GemLoadPaths << file if File.exist?(file = File.join(path, "bin"))
|
||||||
require_paths << file if File.exist?(file = File.join(path, "lib"))
|
GemLoadPaths << file if File.exist?(file = File.join(path, "lib"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# "tag" the first require_path inserted into the $LOAD_PATH to enable
|
# "tag" the first require_path inserted into the $LOAD_PATH to enable
|
||||||
# indexing correctly with rubygems proper when it inserts an explicitly
|
# indexing correctly with rubygems proper when it inserts an explicitly
|
||||||
# gem version
|
# gem version
|
||||||
unless require_paths.empty? then
|
unless GemLoadPaths.empty? then
|
||||||
require_paths.first.instance_variable_set(:@gem_prelude_index, true)
|
GemLoadPaths.first.instance_variable_set(:@gem_prelude_index, true)
|
||||||
end
|
end
|
||||||
# gem directories must come after -I and ENV['RUBYLIB']
|
# gem directories must come after -I and ENV['RUBYLIB']
|
||||||
$:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = require_paths
|
$:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = GemLoadPaths
|
||||||
end
|
end
|
||||||
|
|
||||||
def const_missing(constant)
|
def const_missing(constant)
|
||||||
@ -289,7 +294,6 @@ if defined?(Gem) then
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Gem.push_all_highest_version_gems_on_load_path
|
Gem.push_all_highest_version_gems_on_load_path
|
||||||
Gem::QuickLoader.fake_rubygems_as_loaded
|
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "Error loading gem paths on load path in gem_prelude"
|
puts "Error loading gem paths on load path in gem_prelude"
|
||||||
puts e
|
puts e
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
gem_disabled = !defined? Gem
|
gem_disabled = !defined? Gem
|
||||||
|
|
||||||
|
unless gem_disabled
|
||||||
|
# Nuke the Quickloader stuff
|
||||||
|
Gem::QuickLoader.remove
|
||||||
|
end
|
||||||
|
|
||||||
require 'rubygems/defaults'
|
require 'rubygems/defaults'
|
||||||
require 'thread'
|
require 'thread'
|
||||||
require 'etc'
|
require 'etc'
|
||||||
@ -579,6 +584,12 @@ module Gem
|
|||||||
$LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
|
$LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.remove_prelude_paths
|
||||||
|
Gem::QuickLoader::GemLoadPaths.each do |path|
|
||||||
|
$LOAD_PATH.delete(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# The file name and line number of the caller of the caller of this method.
|
# The file name and line number of the caller of the caller of this method.
|
||||||
|
|
||||||
@ -1098,13 +1109,14 @@ end
|
|||||||
|
|
||||||
require 'rubygems/config_file'
|
require 'rubygems/config_file'
|
||||||
|
|
||||||
|
Gem.remove_prelude_paths
|
||||||
|
|
||||||
##
|
##
|
||||||
# Enables the require hook for RubyGems.
|
# Enables the require hook for RubyGems.
|
||||||
#
|
#
|
||||||
# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
|
# We remove the paths prelude added, so we need custom require to get
|
||||||
# constant at rubygems.rb load time.
|
# any gems now.
|
||||||
|
require 'rubygems/custom_require'
|
||||||
require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9'
|
|
||||||
|
|
||||||
Gem.clear_paths
|
Gem.clear_paths
|
||||||
|
|
||||||
|
@ -17,4 +17,4 @@ end}
|
|||||||
/can't activate rubygems-bug-child.*already activated rubygems-bug-child-1\.1/, [],
|
/can't activate rubygems-bug-child.*already activated rubygems-bug-child-1\.1/, [],
|
||||||
bug3140)
|
bug3140)
|
||||||
end
|
end
|
||||||
end if defined?(::Gem)
|
end if defined?(::Gem) and RUBY_VERSION < "1.9"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user