Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions lib/rubygems/commands/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,8 @@ def generate_default_dirs(install_destdir)
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG['bindir']
else
# Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets
# confused about installation location, so switch back to
# sitelibdir/vendorlibdir.
if defined?(APPLE_GEM_HOME) and
# just in case Apple and RubyGems don't get this patched up proper.
(prefix == RbConfig::CONFIG['libdir'] or
# this one is important
prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby'))
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG['bindir']
else
lib_dir = File.join prefix, 'lib'
bin_dir = File.join prefix, 'bin'
end
lib_dir = File.join prefix, 'lib'
bin_dir = File.join prefix, 'bin'
end

unless install_destdir.empty?
Expand Down
22 changes: 2 additions & 20 deletions lib/rubygems/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,7 @@ def self.default_spec_cache_dir
# specified in the environment

def self.default_dir
path = if defined? RUBY_FRAMEWORK_VERSION
[
File.dirname(RbConfig::CONFIG['sitedir']),
'Gems',
RbConfig::CONFIG['ruby_version'],
]
else
[
RbConfig::CONFIG['rubylibprefix'],
'gems',
RbConfig::CONFIG['ruby_version'],
]
end

@default_dir ||= File.join(*path)
@default_dir ||= File.join(RbConfig::CONFIG['rubylibprefix'], 'gems', RbConfig::CONFIG['ruby_version'])
end

##
Expand Down Expand Up @@ -197,11 +183,7 @@ def self.default_exec_format
# The default directory for binaries

def self.default_bindir
if defined? RUBY_FRAMEWORK_VERSION # mac framework support
'/usr/local/bin'
else # generic install
RbConfig::CONFIG['bindir']
end
RbConfig::CONFIG['bindir']
end

def self.ruby_engine
Expand Down
7 changes: 1 addition & 6 deletions lib/rubygems/path_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,7 @@ def split_gem_path(gpaths, home)

# Return the default Gem path
def default_path
gem_path = Gem.default_path + [@home]

if defined?(APPLE_GEM_HOME)
gem_path << APPLE_GEM_HOME
end
gem_path
Gem.default_path + [@home]
end

def expand(path)
Expand Down
43 changes: 2 additions & 41 deletions test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -931,56 +931,17 @@ def test_self_loaded_specs
assert_equal true, Gem.loaded_specs.keys.include?('foo')
end

def util_path
ENV.delete "GEM_HOME"
ENV.delete "GEM_PATH"
end

def test_self_path
assert_equal [Gem.dir], Gem.path
end

def test_self_path_default
util_path

if defined?(APPLE_GEM_HOME)
orig_APPLE_GEM_HOME = APPLE_GEM_HOME
Object.send :remove_const, :APPLE_GEM_HOME
end
ENV.delete "GEM_HOME"
ENV.delete "GEM_PATH"

Gem.instance_variable_set :@paths, nil

assert_equal [Gem.default_path, Gem.dir].flatten.uniq, Gem.path
ensure
Object.const_set :APPLE_GEM_HOME, orig_APPLE_GEM_HOME if orig_APPLE_GEM_HOME
end

unless win_platform?
def test_self_path_APPLE_GEM_HOME
util_path

Gem.clear_paths
apple_gem_home = File.join @tempdir, 'apple_gem_home'

old, $-w = $-w, nil
Object.const_set :APPLE_GEM_HOME, apple_gem_home
$-w = old

assert_includes Gem.path, apple_gem_home
ensure
Object.send :remove_const, :APPLE_GEM_HOME
end

def test_self_path_APPLE_GEM_HOME_GEM_PATH
Gem.clear_paths
ENV['GEM_PATH'] = @gemhome
apple_gem_home = File.join @tempdir, 'apple_gem_home'
Gem.const_set :APPLE_GEM_HOME, apple_gem_home

refute Gem.path.include?(apple_gem_home)
ensure
Gem.send :remove_const, :APPLE_GEM_HOME
end
end

def test_self_path_ENV_PATH
Expand Down
8 changes: 2 additions & 6 deletions test/rubygems/test_gem_path_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_initialize

assert_equal ENV["GEM_HOME"], ps.home

expected = util_path
expected = ENV["GEM_PATH"].split(File::PATH_SEPARATOR)
assert_equal expected, ps.path, "defaults to GEM_PATH"
end

Expand All @@ -25,7 +25,7 @@ def test_initialize_home

assert_equal File.join(@tempdir, "foo"), ps.home

expected = util_path + [File.join(@tempdir, 'foo')]
expected = ENV["GEM_PATH"].split(File::PATH_SEPARATOR) + [File.join(@tempdir, 'foo')]
assert_equal expected, ps.path
end

Expand Down Expand Up @@ -102,10 +102,6 @@ def test_initialize_home_path
end
end

def util_path
ENV["GEM_PATH"].split(File::PATH_SEPARATOR)
end

def test_initialize_spec
ENV["GEM_SPEC_CACHE"] = nil

Expand Down