Bug #7344
closedgem pristine bigdecimal が失敗してしまう
Added by hsbt (Hiroshi SHIBATA) over 9 years ago. Updated over 9 years ago.
Description
gem pristine bigdecimal を実行すると以下のエラーが発生して落ちてしまいます。
% gem pristine bigdecimal
Restoring gems to pristine condition...
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
/Users/hsbt/.rbenv/versions/2.0.0-dev/bin/ruby extconf.rb
checking for labs() in stdlib.h... yes
checking for llabs() in stdlib.h... yes
creating Makefile
make
compiling bigdecimal.c
linking shared-object bigdecimal.bundle
make install
/usr/local/Cellar/coreutils/8.19/libexec/gnubin/install -c -m 0755 bigdecimal.bundle /Users/hsbt/.rbenv/versions/2.0.0-dev/lib/ruby/gems/2.0.0/gems/bigdecimal-1.1.0/.
/usr/local/Cellar/coreutils/8.19/libexec/gnubin/install: ‘bigdecimal.bundle’ and ‘/Users/hsbt/.rbenv/versions/2.0.0-dev/lib/ruby/gems/2.0.0/gems/bigdecimal-1.1.0/./bigdecimal.bundle’ are the same file
make: *** [install-so] Error 1
単独で実行している時は影響がないのですが、 OS アップデート時などに gem pristine --all を実行した時は b で必ず止まってしまうので困っています。
Updated by mame (Yusuke Endoh) over 9 years ago
- Status changed from Open to Assigned
- Assignee changed from nahi (Hiroshi Nakamura) to mrkn (Kenta Murata)
mrkn さんの作った gem が悪いのでは、という説なので、
とりあえず mrkn さん調べてみてもらえますか?
--
Yusuke Endoh mame@tsg.ne.jp
Updated by mrkn (Kenta Murata) over 9 years ago
ほかの built-in 拡張ライブラリは問題ないんですかねぇ。
そうだとすれば gemspec を真似すればいいのかな。
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
他のライブラリは pure-ruby なので問題無いようです。EM 等にならってビルド時の working ディレクトリを tmp とかにすれば良さそうな気もしますが、rubygems や fake_gem.rb の仕組みをあまりよくわかってないので、パッチまでは作れませんでした。
Updated by kou (Kouhei Sutou) over 9 years ago
RubyGemsに https://github.com/rubygems/rubygems/pull/377 がマージされて、RubyGemsがRuby本体にマージされれば #7427 解決しそうな気がします。RubyGemsの方のpull requestではdefault gemのpristineはスキップするようにしてあるので。
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
gem install bigdecimal でも同様の結果になってしまいました。rubygems/rubygems の #377 でインストールできない問題も解決するのであれば、rubygems 側の変更でよさそうです。
Updated by kou (Kouhei Sutou) over 9 years ago
あぁ、それは解決しないです。そっちはrubygems.orgにあるbigdecimal-1.1.0.gemをダウンロードしてビルドするのでdefault gemとかは関係ない世界になります。
gem install bigdecimalする機会があるのかどうかはおいておくとして、bigdecimal gemがトップレベルにextconf.rbとかbigdecimal.cとかを転がしているのをext/bigdecimal/以下に移動すれば解決するような気がします!
コマンドでいえばこんな感じです。
% mkdir -p ext/bigdecimal
% mv bigdecimal.{c,h} depend extconf.rb ext/bigdecimal/
で、それにあわせてbigdecimal.gemspecをこんな感じに編集します。
Index: bigdecimal.gemspec¶
--- bigdecimal.gemspec (revision 37766)
+++ bigdecimal.gemspec (working copy)
@@ -10,13 +10,13 @@
s.email = "mrkn@mrkn.jp"
s.description = "This library provides arbitrary-precision decimal floating-point number class."
s.authors = ["Kenta Murata", "Shigeo Kobayashi"]
- s.require_path = %[.]
s.files = %w[
bigdecimal.gemspec - bigdecimal.c
- bigdecimal.h
- ext/bigdecimal/bigdecimal.c
- ext/bigdecimal/bigdecimal.h
README
- depend extconf.rb
- ext/bigdecimal/depend
- ext/bigdecimal/extconf.rb
lib/bigdecimal/jacobian.rb
lib/bigdecimal/ludcmp.rb
lib/bigdecimal/math.rb
@@ -26,5 +26,5 @@
sample/nlsolve.rb
sample/pi.rb
]
- s.extensions = %w[extconf.rb]
- s.extensions = %w[ext/bigdecimal/extconf.rb]
end
これで作ったbigdecimal gemをrubygems.orgにpushしておくといいんじゃないかと思います。(バージョンはあげないといけないと思います。)
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
須藤さんありがとうございます。直りそうな気がします!
mrkn よろしくお願いします!
Updated by mrkn (Kenta Murata) over 9 years ago
で、それにあわせてbigdecimal.gemspecをこんな感じに編集します。
このパッチは trunk の ext/bigdecimal/bigdecimal.gemspec に当てれば良いのでしょうか?
Updated by kou (Kouhei Sutou) over 9 years ago
はい。
(もしかして、bigdecimal用の別のリポジトリがあったりします?)
Updated by mrkn (Kenta Murata) over 9 years ago
(もしかして、bigdecimal用の別のリポジトリがあったりします?)
いえ、ありません。ruby の trunk が唯一のリポジトリです。
ところで、io/console にも同じ問題があったりしますか?
Updated by mrkn (Kenta Murata) over 9 years ago
私の手元の環境では、以下の patch を適用し、ruby の top_srcdir で gem build ext/bigdecimal/bigdecimal.gemspec を実行してビルドした gem パッケージを使う事で、install/pristine/uninstall などがきちんと動くことを確認できました。
私は本来の問題を再現する環境の作り方が分からないので、以下の変更で問題ないかどうかレビューまたは確認をしていただけないでしょうか。
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
index 362808c..f52ac22 100644
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ b/ext/bigdecimal/bigdecimal.gemspec
@@ -10,21 +10,22 @@ Gem::Specification.new do |s|
s.email = "mrkn@mrkn.jp"
s.description = "This library provides arbitrary-precision decimal floating-point number class."
s.authors = ["Kenta Murata", "Shigeo Kobayashi"]
- s.require_path = %[.]
- s.require_path = %[ext/bigdecimal/lib/]
s.files = %w[
- bigdecimal.gemspec
- bigdecimal.c
- bigdecimal.h
- README
- depend extconf.rb
- lib/bigdecimal/jacobian.rb
- lib/bigdecimal/ludcmp.rb
- lib/bigdecimal/math.rb
- lib/bigdecimal/newton.rb
- lib/bigdecimal/util.rb
- sample/linear.rb
- sample/nlsolve.rb
- sample/pi.rb
- ext/bigdecimal/bigdecimal.gemspec
- ext/bigdecimal/bigdecimal.c
- ext/bigdecimal/bigdecimal.h
- ext/bigdecimal/README
- ext/bigdecimal/depend
- ext/bigdecimal/extconf.rb
- ext/bigdecimal/lib/bigdecimal/jacobian.rb
- ext/bigdecimal/lib/bigdecimal/ludcmp.rb
- ext/bigdecimal/lib/bigdecimal/math.rb
- ext/bigdecimal/lib/bigdecimal/newton.rb
- ext/bigdecimal/lib/bigdecimal/util.rb
- ext/bigdecimal/sample/linear.rb
- ext/bigdecimal/sample/nlsolve.rb
- ext/bigdecimal/sample/pi.rb
]
- s.extensions = %w[extconf.rb]
- s.extensions = %w[ext/bigdecimal/extconf.rb]
end
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Assignee changed from mrkn (Kenta Murata) to drbrain (Eric Hodel)
いや、これはソースディレクトリとビルドディレクトリ、インストールディレクトリを区別していないrubygemsのバグじゃないでしょうか。
I think the culprit is rubygems, which doesn't separate build, source and install directories.
Updated by drbrain (Eric Hodel) over 9 years ago
=begin
This seems fixed in ruby 2.0.0 preview2 which includes RubyGems 2.0.0.preview2 and default gems:
$ gem20 pristine bigdecimal
Restoring gems to pristine condition...
Skipped bigdecimal-1.1.0, it is a default gem
$ gem20 env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.0.preview2
- RUBY VERSION: 2.0.0 (2012-12-05 patchlevel -1) [x86_64-darwin12.2.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /usr/local/bin/ruby20
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.0.0
- /Users/drbrain/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :benchmark => false
- "gemcutter_key" => "********************************"
- "install" => "--format-executable --no-user-install"
- "update" => "--format-executable --no-user-install"
- "uninstall" => "--format-executable --no-user-install"
- REMOTE SOURCES:
- http://rubygems.org/
=end
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
latest rubygems fixed this issue. I confirmed to solve gem pristine bigdecimal
.
But gem install bigdecimal
always failed now. I think that bigdecimal problems at first. but nobu said it's rubygems defects.
Updated by drbrain (Eric Hodel) over 9 years ago
=begin
I think I understand the comments on this bug thanks to google translate but please inform me of anything important I did not address.
Using recent ruby and rubygems:
$ gem20 env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.0.preview2.1
- RUBY VERSION: 2.0.0 (2012-12-15 patchlevel -1) [x86_64-darwin12.2.1]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /usr/local/bin/ruby20
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.0.0
- /Users/drbrain/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :benchmark => false
- "gemcutter_key" => "********************************"
- "install" => "--format-executable --no-user-install"
- "update" => "--format-executable --no-user-install"
- "uninstall" => "--format-executable --no-user-install"
- REMOTE SOURCES:
- http://rubygems.org/
I can pristine big decimal (like hsbt):
$ gem20 pristine bigdecimal
Restoring gems to pristine condition...
Skipped bigdecimal-1.1.0, it is a default gem
and ((%gem pristine --all%)) works:
$ sudo gem20 pristine --all
Password:
Restoring gems to pristine condition…
[…]
Skipped bigdecimal-1.1.0, it is a default gem
[…]
I can install bigdecimal:
$ gem20 install bigdecimal
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.1.0
Parsing documentation for bigdecimal-1.1.0
Done installing documentation for bigdecimal (1 sec).
1 gem installed
The installed version of bigdecimal and the default gem version are the same, so the installed version can't be used:
$ ruby20 -rbigdecimal -e 'p $".grep(/bigdecimal/)'
["/usr/local/lib/ruby/2.0.0/x86_64-darwin12.2.1/bigdecimal.bundle"]
I don't know if this is a bug in RubyGems or not. kou, can you comment?
You also can't uninstall the duplicate version you installed, this is a bug:
$ gem20 uninstall bigdecimal
ERROR: While executing gem ... (Gem::InstallError)
gem "bigdecimal" cannot be uninstalled because it is a default gem
I will fix this bug ^
NOTE: RubyGems will build bigdecimal.so then install bigdecimal.so and ext/bigdecimal/lib/ into lib/. RubyGems edits the Makefile so ((%make install%)) will copy the files:
https://github.com/rubygems/rubygems/blob/master/lib/rubygems/ext/builder.rb#L19-L23
So source/build directories and lib directories can be separate (but not source, build and lib).
=end
Updated by mrkn (Kenta Murata) over 9 years ago
- Status changed from Assigned to Feedback
I think we need more precise information to reproduce the issue that gem install bigdecimal
is still failed on trunk.
Updated by kou (Kouhei Sutou) over 9 years ago
The installed version of bigdecimal and the default gem version are the same, so the installed version can't be used:
$ ruby20 -rbigdecimal -e 'p $".grep(/bigdecimal/)'
["/usr/local/lib/ruby/2.0.0/x86_64-darwin12.2.1/bigdecimal.bundle"]I don't know if this is a bug in RubyGems or not. kou, can you comment?
Umm... It is difficult... OK. It's a bug in RubyGems. We can fix it by the following change:
Index: specification.rb¶
--- specification.rb (revision 38448)
+++ specification.rb (working copy)
@@ -648,10 +648,10 @@
unless defined?(@@all) && @@all then
specs = {}
-
each_default do |spec|
-
each_normal do |spec| specs[spec.full_name] ||= spec end
-
each_normal do |spec|
-
each_default do |spec| specs[spec.full_name] ||= spec end
I think we need more precise information to reproduce the issue that
gem install bigdecimal
is still failed on trunk.
I think that install command on Mac OS X doesn't report error for the same source and destination file. Could you try the following commands?
% touch a
% install a a
% echo $?
Here is the result on my Debian GNU/Linux:
% touch a
% install a a
install: 'a' and 'a' are the same file
% echo $?
1
I think that install on Mac OS X returns 0 for "echo $?".
Updated by mrkn (Kenta Murata) over 9 years ago
Could you try the following commands?
This is my result:
$ touch a
$ install a a
install: a and a are the same file
$ echo $?
64
$ which install
/usr/bin/install
$ uname -a
Darwin mrkn-mbp15.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
I used GNU install(includes coreutils) in Mac OS. my result is same as kou's result of GNU/Linux.
Updated by kou (Kouhei Sutou) over 9 years ago
Thanks.
It seems that the following commands show a difference:
% touch a
% install a ./
% echo $?
"$?" is 1 on my Debian GNU/Linux. "$?" will be 0 with Mac OS X's native install.
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
mrkn へ(担当者の変更ができない...)
RC1 も出てしまいましたし、以下の変更を trunk に入れて、bigdecimal のバージョンナンバーを更新したのち、gem push をしてもらえないでしょうか。
https://bugs.ruby-lang.org/issues/7344#note-11
現状だと、GNU coreutils の環境、だいたいの Linux で gem install bigdecimal を実行すると失敗します。1.9 でも pristine コマンドで失敗します。標準添付ライブラリがインストールできないというのは格好悪いのでこれだけでも修正できないでしょうか。
Updated by kou (Kouhei Sutou) over 9 years ago
- Assignee changed from drbrain (Eric Hodel) to mrkn (Kenta Murata)
Updated by mrkn (Kenta Murata) over 9 years ago
hsbt (Hiroshi SHIBATA) wrote:
RC1 も出てしまいましたし、以下の変更を trunk に入れて、bigdecimal のバージョンナンバーを更新したのち、gem push をしてもらえないでしょうか。
bigdecimal の修正については了解しました。やります。
io-console も bigdecimal と同じ gemspec の構成になっていますが、こっちは修正しなくても良いのですか?
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
io-console も同じなのにエラーが出ないのは何故と調べてみると、io-console は LOAD_PATH の下でビルドした後に、io というディレクトリを作成して、io/console.so と移動しているため、gnu install でエラーがでないようでした。
Updated by Anonymous over 9 years ago
斎藤と申します。横から失礼します。
gem install bigdecimalが失敗する問題は、BigDecimalのgemに限らず、現状の他の
gemにも波及する問題である、という事を知っていただきたいです。
たとえば拙作ライブラリのgemは、1.9.3では何の問題もなくgem installできますが、
最新の2.0.0に同梱されているgemで試したところ、以下のように、bigdecimalの
ケースに酷似したエラーメッセージと共に、installが失敗します。
$ ruby-2.0.0 -v
ruby 2.0.0dev (2013-01-14 trunk 38812) [x86_64-linux]
$ gem-2.0.0 -v
2.0.0.preview3.1
$ gem-2.0.0 install decimal # gemの名前が似ているのはたまたまです ;)
Building native extensions. This could take a while...
ERROR: Error installing decimal:
ERROR: Failed to build gem native extension.
/home/tadashi/rubies/2.0.0/bin/ruby-2.0.0 extconf.rb
checking for RUBY_VERSION in version.h... no
checking for rb_big_div()... yes
checking for rb_big_modulo()... yes
checking for rb_bigzero_p()... yes
checking for rb_usascii_str_new()... yes
creating Makefile
make
compiling decimal.c
decimal.c: In function ‘divmod’:
decimal.c:1030:8: warning: unused variable ‘div_inum’ [-Wunused-variable]
decimal.c: In function ‘do_round’:
decimal.c:855:47: warning: ‘inum’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
linking shared-object decimal.so
make install
/usr/bin/install -c -m 0755 decimal.so
/home/tadashi/rubies/2.0.0/lib/ruby/gems/2.0.0/gems/decimal-0.1.0/lib
installing default decimal libraries
/usr/bin/install: ./lib/decimal.rb' and
/home/tadashi/rubies/2.0.0/lib/ruby/gems/2.0.0/gems/decimal-0.1.0/lib/decimal.rb'
are the same file
make: *** [/home/tadashi/rubies/2.0.0/lib/ruby/gems/2.0.0/gems/decimal-0.1.0/lib/decimal.rb]
Error 1
Gem files will remain installed in
/home/tadashi/rubies/2.0.0/lib/ruby/gems/2.0.0/gems/decimal-0.1.0 for
inspection.
Results logged to
/home/tadashi/rubies/2.0.0/lib/ruby/gems/2.0.0/gems/decimal-0.1.0/./gem_make.out
ログからは、makeによるビルドは(warningが出るものの)成功していますが、make installで
失敗しているのがお分かりいただけると思います。
これはたしかにgem作者がディレクトリ構成を変えれば回避できますが、逆に申し
上げると、現在installできるgemでも構成を変えない限り、2.0.0になった途端に(API・
コードに互換性はあっても)installできなくなる可能性があるということになります。
これがバグかどうか自分にははっきりしませんが、大きな非互換であるのは明らか
ではないでしょうか。
このようにインストールに失敗するgemがいくつあるのかも、実際にインストール
するか、構成をチェックしてみなければ分かりません。2.0リリース後に阿鼻叫喚する
特定のgem利用者が出るのは間違いないでしょう。またこのディレクトリの仕様変更に
よって、どんなメリットがあるのかも自分は分かりませんでした。
というわけでいちgem作者のお願いとして、
- 2.0.0のリリースか、せめて直後のパッチリリースまでには、上記の振る舞いを元に
戻してインストールできるようにしてほしい - 戻せないのであれば、現行の全gemについて機械的に2.0.0readyであるかチェックし
gem作者に通知してほしい (というのはrubygems.orgの仕事になりそうですね)
というものを要望させていただきたいです。(ただ2は、かなりコストが高く感じます)
その他にも、
- gem作者に、インストール不能になる非互換が発生する旨をアナウンスする
という選択肢もあるかもしれませんが、今まではアナウンスを見たことがないですし、
この時期から新しく出すのでは、すでに遅すぎるのではないかという気がしています。
ご検討をよろしくお願いいたします。
2013/1/14 hsbt (Hiroshi SHIBATA) shibata.hiroshi@gmail.com:
Issue #7344 has been updated by hsbt (Hiroshi SHIBATA).
io-console も同じなのにエラーが出ないのは何故と調べてみると、io-console は LOAD_PATH の下でビルドした後に、io というディレクトリを作成して、io/console.so と移動しているため、gnu install でエラーがでないようでした。¶
Bug #7344: gem pristine bigdecimal が失敗してしまう
https://bugs.ruby-lang.org/issues/7344#change-35401Author: hsbt (Hiroshi SHIBATA)
Status: Feedback
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-13) [x86_64-darwin12.2.1]gem pristine bigdecimal を実行すると以下のエラーが発生して落ちてしまいます。
% gem pristine bigdecimal
Restoring gems to pristine condition...
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension./Users/hsbt/.rbenv/versions/2.0.0-dev/bin/ruby extconf.rb
checking for labs() in stdlib.h... yes
checking for llabs() in stdlib.h... yes
creating Makefilemake
compiling bigdecimal.c
linking shared-object bigdecimal.bundlemake install
/usr/local/Cellar/coreutils/8.19/libexec/gnubin/install -c -m 0755 bigdecimal.bundle /Users/hsbt/.rbenv/versions/2.0.0-dev/lib/ruby/gems/2.0.0/gems/bigdecimal-1.1.0/.
/usr/local/Cellar/coreutils/8.19/libexec/gnubin/install: ‘bigdecimal.bundle’ and ‘/Users/hsbt/.rbenv/versions/2.0.0-dev/lib/ruby/gems/2.0.0/gems/bigdecimal-1.1.0/./bigdecimal.bundle’ are the same file
make: *** [install-so] Error 1単独で実行している時は影響がないのですが、 OS アップデート時などに gem pristine --all を実行した時は b で必ず止まってしまうので困っています。
--
Tadashi Saito
Updated by sorah (Sorah Fukumori) over 9 years ago
sora_h です。
2013/1/15 Tadashi Saito tad.a.digger@gmail.com:
- 2.0.0のリリースか、せめて直後のパッチリリースまでには、上記の振る舞いを元に
戻してインストールできるようにしてほしい- 戻せないのであれば、現行の全gemについて機械的に2.0.0readyであるかチェックし
gem作者に通知してほしい (というのはrubygems.orgの仕事になりそうですね)というものを要望させていただきたいです。(ただ2は、かなりコストが高く感じます)
この話題は ruby-core の方が良さそうだと思いました。
別チケットとして ruby-core に英語で投げる事は可能でしょうか?
--
Shota Fukumori a.k.a. @sora_h - http://sorah.jp/
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
tad さんのご報告にある 1.9 でインストール出来ていた gem が 2.0 ではインストールできない
という問題は bigdecimal に限らないと思いますので、改めて issue を立てて報告した方が良いと思います。
Updated by tad (Tadashi Saito) over 9 years ago
sorahさん、mrknさん、hsbtさん、アドバイスありがとうございます。
(特にチケットの完璧な英訳、ありがとうございました!)
#7698 で須藤さんがそれらしいパッチを投げてくださっているので、
期待したり動作テストしたりしながら待とうと思います。
Updated by kou (Kouhei Sutou) over 9 years ago
- Status changed from Feedback to Closed
- % Done changed from 0 to 100
#7698 を閉じたのでこっちも閉じますね。