LoginSignup
1
1

More than 5 years have passed since last update.

ruby-debugでつまづいた話

Posted at

rbenvを使わずに開発していた頃のプロジェクトのソースを使って、rbenv下で開発環境を再構築しようとしたらハマったのでメモ。

普通にbundle installとかしてrailsサーバを起動すると、以下のようなエラーが出力された。

$ bundle exec rails server
/path/to/project/vendor/bundler/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require': dlopen(/path/to/project/vendor/bundler/ruby/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_threadptr_data_type (LoadError)
  Referenced from: /path/to/project/vendor/bundler/ruby/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
  Expected in: flat namespace
 in /path/to/project/vendor/bundler/ruby/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /path/to/project/vendor/bundler/ruby/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
….

ちなみに、プロジェクトでは元々1.9.2-p290を使っていたので、rbenvでも同じバージョンに合わせている。当然以前はこんなエラーは出てなかった。

同じエラーをググってみるが、「ruby-debugが1.9.3で動かなくなった」というもので同じような現象が報告されてはいるが、ピンとくるものがなかった(ruby-debugではなくてdebuggerを使えというようなものばかり… http://bit.ly/Q5HJcD とか)。

もしかしてrbenvを使っているのが原因かもと、頭を切り替えて探すと、こんなのあった: https://gist.github.com/1403066

これを参考に、bundle configしてインストールしなおしてみた。

$ rm -rf vendor/bundler
$ export RBENV_INCLUDE="$HOME/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/ruby"
$ bundle config build.linecache19 --with-ruby-include=/$RBENV_INCLUDE
$ bundle config build.ruby-debug-base19 --with-ruby-include=/$RBENV_INCLUDE
$ bundle config build.ruby-debug19 --with-ruby-include=/$RBENV_INCLUDE
$ bundle install

この結果、エラーが出ずに動くようになった。

とここまで、書いてみて気が付いたが、よく考えたら最初、ruby 1.9.3でbundle installして、実行したら冒頭のエラーが出たので、「あ、1.9.3じゃ動かないだ」と思って1.9.2に切り替えたのだった。切り替えて実行してやっぱりエラーになったので、調べ始めたわけで…。

ということは、上記のbundle configがなくても最初からruby 1.9.2でbundle installすれば動くのではと思い試してみた。

$ rm -rf vendor/bundler
$ rm $HOME/.bundle/config
$ bundle install

やってみたら、何もエラー出ずに動く…。なんだ〜。
ということで、さようなら。

1
1
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
1
1