diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-03-08 13:11:54 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-03-08 23:23:45 +0000 |
commit | cb3f1f6de8bd2e128168fde43aa28c2441818469 (patch) | |
tree | 5d36a0bd9b3836570944f087cf675d3e00bd328f /lib | |
parent | 309dd50a01203ac107c12e5a962e6aa6add75529 (diff) |
[rubygems/rubygems] Detect extension files under full_required_paths
When we use this methods with local gemspec, we don't handle
build status of extension correctly. So We need to find extension
files in require_paths.
Example with ruby/erb repository:
```
$ bundle exec irb
Ignoring erb-4.0.2 because its extensions are not built. Try: gem pristine erb --version 4.0.2
>>
```
https://github.com/rubygems/rubygems/commit/f90e43cf3f
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/specification.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index b8006671e9..be9d7a4953 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -12,6 +12,8 @@ require_relative "stub_specification" require_relative "platform" require_relative "util/list" +require "rbconfig" + ## # The Specification class contains the information for a gem. Typically # defined in a .gemspec file or a Rakefile, and looks like this: @@ -2182,6 +2184,16 @@ class Gem::Specification < Gem::BasicSpecification return false if default_gem? return false if File.exist? gem_build_complete_path + # When we use this methods with local gemspec, we don't handle + # build status of extension correctly. So We need to find extension + # files in require_paths. + # TODO: Gem::Specification couldn't access extension name from extconf.rb + # so we find them with heuristic way. We should improve it. + return false if (full_require_paths - [extension_dir]).any? do |path| + File.exist?(File.join(path, "#{name}.#{RbConfig::CONFIG['DLEXT']}")) || + !Dir.glob(File.join(path, name, "*.#{RbConfig::CONFIG['DLEXT']}")).empty? + end + true end |