LoginSignup
12
6

More than 5 years have passed since last update.

エラー発生時における公式ドキュメント(英語)の重要性について

Posted at

概要①

(非常によくあるであろう!)『libv8』絡みで四苦八苦した結果、
libv8の公式ドキュメント( https://github.com/cowboyd/libv8 )に従ったら一発で解消した経験を共有します。

「英語だからむーりー」とか言ってはいけません。

かのユリウス・カエサル・ツェペリも言っています。
「一番の近道は遠回りだった」
「遠回りこそが俺の最短の道だった」
と…

概要②

macでlibv8でエラーが発生したら、
公式ドキュメント( https://github.com/cowboyd/libv8 )に従いましょう。

「ruby -e 'puts Gem::Platform.local'」でlibv8のバージョンを確認しましょう。

古かったらrubyのバージョンを変えるなり、再インストールしてみましょう。

シチュエーション

react_on_railsのexampleである、
react-webpack-rails-tutorial( https://github.com/shakacode/react-webpack-rails-tutorial )
のセットアップ過程でbundle installエラーが発生。

bundle installのエラー

An error occurred while installing mini_racer (0.1.7), and Bundler
cannot continue.
Make sure that `gem install mini_racer -v '0.1.7'` succeeds before bundling.

私「なんかよく分からんが、mini_racerってやつが原因なんだな!よしググろう!」

「mini_rancer error」でググる => 全滅

私「なんか同じようなシチュエーションでエラーの事例無いんですが…」

エラー文をよく読む

(Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

私「あれ!よく読んだら、『libv8が見つかりません』って言ってるぞ!よしググろう!」

「libv8 error」でググる => 全滅

私「おー!qiita(日本語)で対処がいっぱい出てくるじゃん!全部試せば何とかなるでしょ!」

⇛全滅。エラー解消せず。

libv8の公式ドキュメントをあたる => エラー解消

Note on OS X macOS binaries

If you're installing libv8 on a macOS system that is present in the list above, 
and despite that, RubyGems insists on downloading a source version and compiling it, 
check the output of ruby -e 'puts Gem::Platform.local'. 
If it does not reflect the current version of your OS, recompile Ruby.

The platform gets hardcoded in Ruby during compilation and if you've updated your OS since you've compiled Ruby, 
it does not represent correctly your current platform which leads to RubyGems trying to download a platform-specific gem for the older version of your OS.

「よし!『ruby -e 'puts Gem::Platform.local'』を試そう!それで古いやつならrbenvよりrubyを変えれば良いんだな!」

⇛大成功。rubyのバージョンを切り替えることで、「x86_64-darwin-16」になり、エラーが解消。
 (capybara-webkitのインストールでエラーが発生したのは、また別のお話。。。)
 (まあそれも、公式ドキュメントに従って、qmakeコマンドのPATHを通したら解消したんですが。)

私「本当に…ありがとう…それしか言う言葉が見つからない…」

結論

アンチパターン:
とにかく頭ごなしにググる⇛日本語のドキュメントの答えを試す⇛結果に一喜一憂する

ベスト・プラクティス:
エラー文をよく読む⇛エラー対象に目星をつける⇛エラー対象の公式ドキュメントでエラー対処方法を探す⇛解決

個人的な意見

アンチパターンには2つの良くない点があると思います。
①開発者ではない人間が記述してるため、シチュエーションの違うエラー(ex.バージョンが違う)に対処できないことがある。
②エラーの対処法しか読み取れず、エラーの背景(=システムに関する知識)を学習できない。

それに対して、ベスト・プラクティスは下記の良い点があると思います。
①開発者が記述しているため、エラー内容/対処が詳細に記述している。
②エラー内容が詳細に記述されているため、エラーの背景(=システムに関する知識)が学習できる。

以上より、エラー発生時は「学習の機会だ」と捉え、公式ドキュメントに当たるべきだと考えます。

P.S.

この記事は、ド素人のエンジニアの個人的見解であり、人によって「おかしいだろ!」と思うこともあると思います。
その時はぜひコメントより、ご意見をよろしくお願いします。

P.S.S.

7部は最高。

12
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
6