Skip to content
Closed
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
7 changes: 7 additions & 0 deletions bundler/spec/support/hax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ class << self
end
end
end

class Specification < BasicSpecification
if defined?(DEFAULT_GEMS_LIST)
remove_const :DEFAULT_GEMS_LIST
DEFAULT_GEMS_LIST = %w[irb json foo bar].freeze
end
end
end
19 changes: 15 additions & 4 deletions lib/rubygems/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,15 @@ def install
dir_mode = options[:dir_mode]
FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0o755

extract_files

build_extensions
write_build_info_file

if @options[:install_as_default]
extract_bin
write_default_spec
else
extract_files

build_extensions
write_build_info_file
run_post_build_hooks
end

Expand Down Expand Up @@ -760,6 +761,12 @@ def verify_spec
end
end

def verify_default_gems
return unless options[:install_as_default]
return if Gem::Specification::DEFAULT_GEMS_LIST.include?(spec.name)
raise Gem::InstallError, "#{spec} is not a default gem."
end

##
# Return the text for an application file.

Expand Down Expand Up @@ -925,6 +932,10 @@ def pre_install_checks

ensure_loadable_spec

verify_spec

verify_default_gems

if options[:install_as_default]
Gem.ensure_default_gem_subdirectories gem_home
else
Expand Down
26 changes: 26 additions & 0 deletions lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,32 @@ class Gem::Specification < Gem::BasicSpecification

VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:

DEFAULT_GEMS_LIST = %w[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this pull from Gem::Specification.select(&:default_gem?).map(&:name) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not working. default gems were determined without ruby version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default gems were determined without ruby version

I'm not sure I understand what you mean by this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default gems do not depend on Ruby version.

Ex. We can install default gems from listed by https://stdgems.org/ with old ruby. But is not activated in the current specification. I hope to activate them with old ruby.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, good point

bigdecimal
bundler
cmath
csv
date
dbm
etc
fcntl
fiddle
fileutils
gdbm
io-console
ipaddr
json
openssl
psych
rdoc
scanf
sdbm
stringio
strscan
webrick
zlib
].freeze # :nodoc:

# :startdoc:

##
Expand Down
5 changes: 5 additions & 0 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def self.specific_extra_args_hash=(value)
end
end

class Gem::Specification < Gem::BasicSpecification
remove_const :DEFAULT_GEMS_LIST
DEFAULT_GEMS_LIST = %w[systemgem default bundler a b c z].freeze
end

##
# RubyGemTestCase provides a variety of methods for testing rubygems and
# gem-related behavior in a sandbox. Through RubyGemTestCase you can install
Expand Down