带有ruby-debugger的Rails抛出“找不到符号:_ruby_current_thread(LoadError)”

我有标准的红宝石头和Rails 3.1rc4。我按照[http://dirk.net/2010/04/17/ruby-debug-with-ruby-19x-and-rails-3-on-rvm/]中的说明安装了ruby-debug

但是,当我运行rails s --debugger时,它将引发此奇怪的错误

/Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require': dlopen(/Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
  Referenced from: /Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle
  Expected in: flat namespace
in /Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle - /Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle
from /Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `block in require'
from /Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `block in load_dependency'

任何想法?谢谢大卫

Schovi asked 2020-01-13T02:01:41Z
7个解决方案
54 votes

更新:

看起来您只需要将其放入您的gemfile中:

宝石“调试器”

现在可以了。

旧文章如下

===================================

Jerome是正确的,但缺乏细节。 这是从[[https://gist.github.com/1331533]摘录而来的,特别是感谢安德鲁罗斯的帖子。 截至本文发布时,我已经对此进行了测试。 人们希望这些更改将很快部署到某个标准位置。

Installing ruby debugger on ruby 1.9.3-p125: 

export PATCH_LEVEL=`ruby -e 'puts RUBY_PATCHLEVEL'`
export RVM_SRC=$HOME/.rvm/rubies/ruby-1.9.3-p$PATCH_LEVEL/include/ruby-1.9.1
gem install archive-tar-minitar
gem install ruby_core_source -- --with-ruby-include=/$RVM_SRC
export RVM_SRC=$HOME/.rvm/rubies/ruby-1.9.3-p$PATCH_LEVEL/include/ruby-1.9.1/ruby-1.9.3-p$PATCH_LEVEL

wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
# if that step failed, and you are running OSX Lion, then following this post can help you: 
# http://stackoverflow.com/questions/8032824/cant-install-ruby-under-lion-with-rvm-gcc-issues
# this happens if you recently installed xcode from the app store. 
# bizarrely, for me I had to do this: ln -s /usr/bin/gcc /usr/bin/gcc-4.2
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC

Then edit Gemfile: 

gem 'linecache19', '0.5.13', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/linecache19-0.5.13/"
gem 'ruby-debug-base19', '0.11.26', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/ruby-debug-base19-0.11.26/"
gem 'ruby-debug19', :require => 'ruby-debug'

Then install: 

bundle install
Rob answered 2020-01-13T02:02:16Z
21 votes

我使用了gem'debugger',它是ruby-debug(19)的一个分支,可在1.9.2和1.9.3上运行,并且可以很容易地安装rvm / rbenv红宝石。它使错误消失!

Mustafah answered 2020-01-13T02:02:36Z
11 votes

目前看来,这是ruby-debug-base中的一个已知错误。 我已将我的评论添加到错误跟踪器的问题上。 请考虑添加您的注释:

[http://rubyforge.org/tracker/index.php?func=detail&aid=29222&group_id=8883&atid=34290]

同时,ruby 1.9具有内置的调试器。 它只是非常缓慢。 手动将此要求行添加到您的代码中:

require 'debug'

另外,调试器默认情况下会中断所有StandardError异常,因此在首次启动时执行此操作:

catch off
Travis Warlick answered 2020-01-13T02:03:10Z
6 votes

如果您正在运行Ruby 1.9.3x,要对其进行修复,请转至rubyforge上的ruby-debug,下载并安装ruby-debug-base 0.11.26和linecache19 0.5.13。 修改您的Gemfile以使用这些文件,然后运行

bundle update ruby-debug-base19

调试器现在应该可以工作了。

谢谢杰罗姆

jtblin answered 2020-01-13T02:03:39Z
0 votes

这是固定升级到所有调试的最新瑰宝

Rubytastic answered 2020-01-13T02:03:59Z
0 votes

使用ruby 1.9.3,我可以通过在'ruby-debug19'之外添加gem'ruby-debug-base19x'(请注意名称末尾的'x')来使其工作。

EK0 answered 2020-01-13T02:04:19Z
0 votes

我的系统在Mac OSX 10.8.5上是rvm 1.18.10和ruby 1.9.3p392。 我首先安装了gem'ruby-debug19',但是由于众所周知的原因,调试器无法正常工作。

然后我跑了

local$ gem install 'debugger'

正如许多其他职位所建议的那样。 gem已成功安装,并具有以下输出:

local$ gem install debugger
Fetching: debugger-ruby_core_source-1.2.3.gem (100%)
Fetching: debugger-linecache-1.2.0.gem (100%)
Fetching: debugger-1.6.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed debugger-ruby_core_source-1.2.3
Successfully installed debugger-linecache-1.2.0
Successfully installed debugger-1.6.2
3 gems installed
Installing ri documentation for debugger-ruby_core_source-1.2.3...
Installing ri documentation for debugger-linecache-1.2.0...
Installing ri documentation for debugger-1.6.2...
Installing RDoc documentation for debugger-ruby_core_source-1.2.3...
Installing RDoc documentation for debugger-linecache-1.2.0...
Installing RDoc documentation for debugger-1.6.2...
local$ irb
1.9.3-p392 :002 > require 'debugger'
=> true

然后我跑了

local$ rails server --debug
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:
in`require': dlopen(/usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle,
9): Symbol not found: _ruby_current_thread (LoadError)
Referenced from: /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
 in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
......

我通过注释掉“ gem'ruby-debug19'”行并在Gemfile中添加了新行“ gem'debugger'”来解决了该错误,然后运行

local$ bundle update

之后,一切正常。

local$ rails server --debug
=> Booting WEBrick
=> Rails 3.2.14 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
=> Debugger enabled
[2013-10-15 12:50:21] INFO  WEBrick 1.3.1
[2013-10-15 12:50:21] INFO  ruby 1.9.3 (2013-02-22) [x86_64-darwin10.8.0]
[2013-10-15 12:50:21] INFO  WEBrick::HTTPServer#start: pid=7206 port=3000
Julia Zhao answered 2020-01-13T02:05:01Z
translate from https://stackoverflow.com:/questions/6438116/rails-with-ruby-debugger-throw-symbol-not-found-ruby-current-thread-loaderro