[前][次][番号順一覧][スレッド一覧]

ruby-changes:61605

From: Yusuke <ko1@a...>
Date: Tue, 9 Jun 2020 00:34:44 +0900 (JST)
Subject: [ruby-changes:61605] a3cc9b3c8e (master): Avoid requiring "psych/versions"

https://git.ruby-lang.org/ruby.git/commit/?id=a3cc9b3c8e

From a3cc9b3c8e8e55660e434015654dfc4e11e3a3ab Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 9 Jun 2020 00:27:04 +0900
Subject: Avoid requiring "psych/versions"

This leads to double requiring "ext/psych/lib/psych/versions.rb" and
".ext/common/psych/versions.rb", which produces doxens of warnings
during `make test-all`.

http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200608T123004Z.log.html.gz
```
[15092/20234]
TestRDocOptions#test_init_with_encoding/home/chkbuild/chkbuild/tmp/build/20200608T123004Z/ruby/ext/psych/lib/psych.rb:233: warning: already initialized constant Psych::LIBYAML_VERSION
/home/chkbuild/chkbuild/tmp/build/20200608T123004Z/ruby/.ext/common/psych.rb:233: warning: previous definition of LIBYAML_VERSION was here
/home/chkbuild/chkbuild/tmp/build/20200608T123004Z/ruby/ext/psych/lib/psych.rb:235: warning: already initialized constant Psych::NOT_GIVEN
/home/chkbuild/chkbuild/tmp/build/20200608T123004Z/ruby/.ext/common/psych.rb:235: warning: previous definition of NOT_GIVEN was here
/home/chkbuild/chkbuild/tmp/build/20200608T123004Z/ruby/ext/psych/lib/psych.rb:271: warning: method redefined; discarding old load
/home/chkbuild/chkbuild/tmp/build/20200608T123004Z/ruby/.ext/common/psych.rb:271: warning: previous definition of load was here
...
```

The same issue happened in fiddle.gemspec, and this change applies the
same fix as [fiddle](https://github.com/ruby/fiddle/issues/34).

diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec
index f47029e..8c81e56 100644
--- a/ext/psych/psych.gemspec
+++ b/ext/psych/psych.gemspec
@@ -1,14 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L1
 # -*- encoding: utf-8 -*-
 # frozen_string_literal: true
 
-lib_path = File.expand_path('lib', __dir__)
-$LOAD_PATH.unshift lib_path if File.exist?(lib_path)
-
-require 'psych/versions'
+version_module = Module.new do
+  version_rb = File.join(__dir__, "lib/psych/versions.rb")
+  module_eval(File.read(version_rb), version_rb)
+end
 
 Gem::Specification.new do |s|
   s.name = "psych"
-  s.version = Psych::VERSION
+  s.version = version_module::Psych::VERSION
   s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
   s.email = ["aaron@t...", "hsbt@r...", "headius@h..."]
   s.summary = "Psych is a YAML parser and emitter"
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]