@@ -52,10 +52,39 @@ def system(*commands)
5252 super ( *commands )
5353end
5454
55+ # Gemfile は BITCLUST_PATH(既定値 ../bitclust)にディレクトリが存在すると
56+ # そちらの bitclust を優先する。古いチェックアウトが残っていると
57+ # `cannot load such file -- drb` や `invalid option: --markdowntree` のような
58+ # 分かりにくいエラーで失敗するので、ビルド前に検査して案内を出す
59+ # (https://github.com/rurema/bitclust/issues/230)
60+ REQUIRED_BITCLUST_VERSION = Gem ::Version . new ( "1.5.0" )
61+ def check_bitclust_version!
62+ begin
63+ require "bitclust/version"
64+ rescue LoadError
65+ abort "bitclust を読み込めませんでした。bundle install を実行してください。"
66+ end
67+ version = Gem ::Version . new ( BitClust ::VERSION )
68+ return if version >= REQUIRED_BITCLUST_VERSION
69+ location = $LOADED_FEATURES. grep ( %r{bitclust/version\. rb\z } ) . first
70+ abort <<~MESSAGE
71+ 古い bitclust (#{ version } ) が使われています(#{ REQUIRED_BITCLUST_VERSION } 以上が必要です)。
72+ 使用中の bitclust: #{ location }
73+ doctree の Gemfile は、環境変数 BITCLUST_PATH(既定値 ../bitclust)の
74+ ディレクトリが存在するとそちらの bitclust を優先します。過去に clone した
75+ 古い bitclust が残っている場合は、次のいずれかで解決してから
76+ bundle install をやり直してください:
77+ * ../bitclust を最新にする (cd ../bitclust && git pull)
78+ * ../bitclust を使わないなら、ディレクトリを削除・改名するか、
79+ BITCLUST_PATH=/nonexistent のように存在しないパスを指定する
80+ MESSAGE
81+ end
82+
5583# ソースは manual/ の Markdown ツリー(manual/doc は manual/api から自動で取り込まれる)。
5684# 旧 refm/ は移行ウィンドウ中の凍結ソース。旧経路でビルドしたい場合は
5785# BITCLUST_SOURCE=refm を指定する。
5886def generate_database ( version )
87+ check_bitclust_version!
5988 puts "generate database of #{ version } "
6089 db = "/tmp/db-#{ version } "
6190 succeeded = system ( "bundle" , "exec" ,
@@ -81,6 +110,7 @@ def generate_database(version)
81110end
82111
83112def generate_statichtml ( version )
113+ check_bitclust_version!
84114 db = "/tmp/db-#{ version } "
85115 generate_database ( version ) unless File . exist? ( db )
86116 puts "generate static html of #{ version } "
0 commit comments