在ruby-1.9.3-preview1上使用ruby-debug19

8

可能是重复问题:
{{link1:Rails 3.1和Ruby 1.9.3p125:ruby-debug19仍然崩溃,显示“Symbol not found: _ruby_threadptr_data_type”}}

我在ruby 1.9.3 preview1版本上调试时遇到了一些问题。

我使用以下命令使用rvm安装了1.9.3:

rvm install 1.9.3 --reconfigure --debug -C --enable-pthread

使用以下命令安装了ruby-debug19:

gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-preview1

安装debug gem没有问题,但是当我尝试使用调试控制台或者带有debug标志的命令rails c --debug或者rspec spec --debug时,出现以下错误:

/Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require': dlopen(/Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
  Referenced from: /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
  Expected in: flat namespace
 in /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler/runtime.rb:68:in `require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler/runtime.rb:66:in `each'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler/runtime.rb:55:in `each'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler/runtime.rb:55:in `require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@global/gems/bundler-1.0.17/lib/bundler.rb:120:in `require'
    from /Users/mario/Work/project/config/application.rb:7:in `<top (required)>'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/railties-3.0.9/lib/rails/commands.rb:21:in `require'
    from /Users/mario/.rvm/gems/ruby-1.9.3-preview1@project/gems/railties-3.0.9/lib/rails/commands.rb:21:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

你正在走在 Lion 和 1.9.3-preview 之间的尖端,你可能需要直接联系 ruby-debug 的作者/支持者。 - the Tin Man
是的,我明白了。我想提出这个问题是为了看看是否有人已经有了解决方案或者是否有什么我漏掉的地方。如果没有人提供任何信息,我会提交一个工单。 - Mario Visic
请参见以下链接:https://dev59.com/Mmw15IYBdhLWcg3wuuGn#7096617 - Travis Warlick
6个回答

13

以下是我在一个Gist中找到的另一种解决方案,作者是rafaeldx7

基本上,解决方案是使用更新版本的几个库,linecache19 v0.5.13 和ruby-debug-base19 v0.11.26,这两个库都还没有被加入 RubyGem 仓库。

# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug

echo "Installing ruby-debug with ruby-1.9.3-p0 ..."

curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem

gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0/

rm linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem

echo "Done."

3
不要错过在评论中隐藏的简单安装:bash < <(curl -L https://raw.github.com/gist/1333785) - Matt Scilipoti
对于那些没有 Ruby 源代码的 rbenv 用户(替换您的 Ruby 版本号):gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem -- --with-ruby-include=~/.rbenv/versions/1.9.3-p125/include/ruby-1.9.1/ruby-1.9.3-p125 - gerrit

7

编辑:最初,git-pinning解决方案起作用,但我一直无法始终使用它。我将保留它在这里,因为人们已经点赞了,但我认为我的ruby-debug CLI是偶然起作用的,因为它的打包方式不太常规。

我建议使用pry代替,它似乎比ruby-debug更好。此外,我也使用require 'debug'一段时间了,就像回答顶部提到的那样(可能是人们点赞的原因),它将让你进入的范围通常与你的预期不同。再次强调,使用pry(如果您想要类似于调试器的步骤,则还需要这个pry插件,我尚未需要/测试)。


在我发现以下内容之后,看到Rails with ruby-debugger throw 'Symbol not found: _ruby_current_thread (LoadError)'(摘要:您现在可以使用1.9内置的调试器):

既然我注意到您正在尝试使其与Rails一起工作,那么如果您正在使用bundler,则可以将以下内容添加到gemfile中:

gem 'linecache19', :git => 'https://github.com/mark-moseley/linecache.git' 
gem 'ruby-debug-base19', :git => 'https://github.com/mark-moseley/ruby-debug.git'

然后执行:

bundle config build.ruby-debug-base19 --with-ruby-include="$rvm_path/src/$(rvm tools strings)/"
bundle install

1
即使我写上 :require => 'ruby-debug',我仍然会得到“无法加载文件--ruby-debug”的错误。 - Scott Schulthess
是的,我肯定设置得很好。我在另一个项目中无法重现它。问题在于ruby-debug-base19的“package”任务会生成两个gem,一个用于基础,一个用于CLI解释器。看起来这些曾经是两个项目,但已合并?不确定为什么,但这使得它难以像这样使用。无论如何,我更新了我的解决方案来建议使用“pry”。 - Woahdae

3
我已经创建了一个Rubygems仓库,其中包括1.9.3的最新版本。只需在您的Gemfile中添加此源代码行,就可以完成全部设置:
source 'http://rubydebug19.s3.amazonaws.com'

gem 'ruby-debug19', :group => :development

干得好!我已经厌倦了在每个项目中重新学习如何处理这个问题! - Troy

0

这里有一个临时解决方案:http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug

来自该网站的摘录:

First download linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem from http://rubyforge.org/frs/?group_id=8883, then …

$ gem install linecache19-0.5.13.gem 
Building native extensions.  This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
$ gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users/santiago/.rbenv/source/ruby-1.9.3-p0  
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
$ irb
irb(main):001:0> require 'ruby-debug'
=> true

1
只返回翻译后的文本:如果链接在未来消失,仅包含链接的答案是没有用的。您能否总结或解释一下那里所说的内容? - Kate Gregory

0

以下是我使用Bundler 1.x和Ruby 1.9.3-p0(发布的稳定版本)使事情正常运行的方法。希望这很快就会过时,但在此期间,如果您需要,这是一个可行的解决方法。

首先,将linecache和ruby-debug-base gem作为系统gem安装。请注意,我从不同的地方获取了它们。

$ curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
$ gem install linecache19-0.5.13.gem
$ gem install --pre ruby-debug-base19x # installs ruby-debug-base19x-0.11.30.pre4

接下来,为每个已安装的宝石重建它们的源代码:
$ mkdir ~/src/linecache19
$ cd /r193 # where your 1.9.3 is installed; system dependent
$ cd lib/ruby/gems/1.9.1 # where your gems are, should be the same
$ cp specifications/linecache19.gemspec ~src/linecache19
$ cp -r gems/linecache19-0.5.13/* ~/src/linecache19

$ mkdir ~/src/ruby-debug-base19x
$ cp specifications/ruby-debug-base19x-0.11.30.pre4.gemspec ~/src/ruby-debug-base19x
$ cp -r ruby-debug-base19x-0.11.30.pre4/* ~/src/ruby-debug-base19x

现在你可以使用:path指令在Gemfile中引用这些目录。如果你有一个本地的git仓库,你可以将这些目录提交到仓库中,并从Gemfile中引用它们,就像这样:
group :development do
  gem 'linecache19', '~>0.5.12', :git => 'git://git-repo/ruby/linecache19.git'
  gem 'ruby-debug-base19x', :git => 'git://git-repo/ruby/ruby-debug-base19x.git'
  gem 'ruby-debug19', :require => 'ruby-debug'
  gem 'ruby-prof'
end

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接