[英]How do I debug a Ruby gem? (Compass)
I am in the early stages of learning Ruby and want to learn how to debug a gem, but am having trouble finding learning resources around this. 我正处于学习Ruby的早期阶段,并且想学习如何调试gem,但是我很难找到学习资源。 A simple example would go a long way for me.
一个简单的例子对我来说有很长的路要走。
Is debugger the preferred debugger? 调试器是首选调试器吗? Where do I require it?
我在哪里需要它? How do I set breakpoints with it?
如何设置断点?
Note: I am making an educated guess that the debugging process may be different depending on the gem that needs debugging, so for reference I am particularly interested in debugging certain issues with Compass . 注意:我正在做出有根据的猜测,根据需要调试的gem,调试过程可能会有所不同,因此作为参考,我对使用Compass 调试某些问题特别感兴趣。
OK, figured this out on my own. 好吧,我自己想出来了。 Here were the steps I took..
这是我采取的步骤..
I am running Ruby 1.9.3 (determined by running ruby -v
), so after testing ruby-debug and ruby-debug19 , I determined these debuggers were no longer maintained, or at least didn't work properly with my install of ruby1.9.3-p125. 我正在运行Ruby 1.9.3(通过运行
ruby -v
确定),所以在测试ruby-debug和ruby-debug19之后 ,我确定这些调试器不再被维护,或者至少在我安装ruby1时无法正常工作。 9.3-P125。 This lead me to debugger . 这导致我调试 。
The install instructions that worked were: 有效的安装说明是:
$ gem install debugger -- --with-ruby-include=PATH_TO_HEADERS
The PATH_TO_HEADERS on my machine, was simply the source location of ruby: 我机器上的PATH_TO_HEADERS只是ruby的源位置:
/Users/myusername/.rvm/src/ruby-1.9.3-p125/
Since I was particularly determined to debug the Compass compiler, I did the following: 由于我特别决定调试Compass编译器,所以我做了以下事情:
$ git clone git://github.com/chriseppstein/compass.git
$ git clone git://github.com/chriseppstein/compass.git
$ compass -v
which was 13.0 $ compass -v
是13.0 lib/compass/compiler.rb
and added this line at the top: require 'debugger'; debugger
lib/compass/compiler.rb
并在顶部添加了这行: require 'debugger'; debugger
require 'debugger'; debugger
gem build compass.gemspec
gem build compass.gemspec
sudo gem install compass-0.13.2.058ead2.gem
sudo gem install compass-0.13.2.058ead2.gem
sudo gem uninstall compass
and chose the number corresponding to Compass 13.2. sudo gem uninstall compass
卸载了调试版本,并选择了与Compass 13.2相对应的编号。 Note about step 7: Since debugger has the same debugging commands as ruby-debug/ruby-debug19, I was able to follow existing tutorials around debugging steps.. 关于步骤7的注意事项:由于调试器具有与ruby-debug / ruby-debug19相同的调试命令,因此我能够按照现有的调试步骤进行调试。
If you have other debugger tutorials, pointers, tips, etc, please post them. 如果您有其他调试器教程,指针,提示等,请发布它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.