X- [英] Configuring gems in eclipse

查看:109
本文介绍了X-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在日食中的一个流浪/厨师项目上工作。我对这两种技术来说都是新鲜事,有一点生锈的红宝石。我已经安装了rdt并且有一个Ruby代码的项目。



然而,eclipse似乎不明白宝石是必需的。有没有办法让红宝石宝石和日食一起玩得很好。我以为我可以添加宝石作为图书馆,但似乎不起作用。

解决方案

我有一个非常类似的问题,让Eclipse识别我安装的宝石。
我正在使用 rvm ,默认指向ruby 2.1.0。
我正在调试的ruby代码有一个需要'mail'在顶部。
运行或调试脚本时,控制台显示错误:

  /Users/username/.rvm/rubies /ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in`require':无法从/ Users / ...中加载这样的文件 - 邮件(LoadError)
username / .rvm / rubies / ruby​​-2.1.0 / lib / ruby​​ / site_ruby / 2.1.0 / ruby​​gems / core_ext / kernel_require.rb:54:在`require'
`< main>'
/ b
$ p
$ b

Eclipse的首选项> Ruby> Interpreters中配置了正确的ruby: / Users / username /.rvm/rubies/ruby-2.1.0/bin/ruby



我知道邮件 gem已安装在Eclipse之外的那个ruby:

  $ gem其中邮件
/ Users / username / .rvm / gems / ruby​​-2.1.0 / gems / mail-2.6.3 / lib / mail.rb

我尝试@Don Kirkby的建议是在调试配置中添加 -rubygems 作为解释器参数,但仍然不起作用。



什么都搞不定,奇怪的是,被添加 GEM_HOME GEM_PATH 变量的调试配置的环境部分



我发现正确的值(由RVM设置,我相信)通过回送他们在终端,Eclipse之外:

  $ $回声GEM_HOME 
/Users/username/.rvm/gems/ruby-2.1.0
$ echo $ GEM_PATH
/Users/username/.rvm/gems/ruby-2.1.0:/Users/username/.rvm/gems/ruby-2.1.0@global

在Debug Configurations> Environment选项卡中将这两个作为环境变量添加到Eclipse中,使用 Ruby内置调试器作为首选项中的调试引擎。
顺便说一句,我尝试使用'Fast Ruby Debugger(ruby-debug)'引擎,但是收到这个错误:

  dyld:lazy符号绑定失败:找不到符号:_rb_vm_get_sourceline 
引用自:/Users/username/.rvm/gems/ruby-2.1.0/extensions/x86_64-darwin-12/2.1.0-static/debugger -1.6.8 / ruby​​_debug.bundle
预期在:平面命名空间

dyld:找不到符号:_rb_vm_get_sourceline
引用来自:/Users/username/.rvm/gems/ruby -2.1.0 / extensions / x86_64-darwin-12 / 2.1.0-static / debugger-1.6.8 / ruby​​_debug.bundle
期望为:flat namespace

旁注:试图追捕修复到符号没有发现误差导致快速Ruby调试发动机我到这个主题:在ruby 1.9中调试1.9,这似乎意味着<$宝石适合于使用ruby 2.0+,而且还可以使用ruby-debug 而是建议 byebug 宝石。但是,由于我没有看到使用Eclipse的方式来使用 byebug ,所以我刚刚结束了使用 Ruby Built-In Debugger 引擎与调试器 ruby​​-debug-ide gems:

  $ gem install debugger 
成功安装debugger-1.6.8
$ gem install ruby​​-debug-ide
成功安装ruby-debug我从这篇文章得到的-ide-0.4.26

https://endocode.com/blog/2012/09/ 03 / debug-ruby-1-9-3-application-in-eclipse /



希望这对有意尝试获得Ruby 1.9 / 2.0+调试工作与Eclipse。


I'm trying to work on a vagrant / chef project in eclipse. I'm fairly new to both technologies and a little rusty with ruby. I've installed rdt and have a ruby project with the code in.

However, eclipse doesn't seem to understand that gems are required. Is there a way to get ruby gems and eclipse to play nicely together. I thought that I could add gems as libraries but that doesn't seem to work.

解决方案

I was having a very similar problem of getting Eclipse to recognize my installed gems. I was using rvm, with the default pointing to ruby 2.1.0. The ruby code that I was debugging had a single require 'mail' at the top. When running or debugging the script, the console displayed an error:

/Users/username/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mail (LoadError)
     from /Users/username/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
`<main>'

Eclipse had the correct ruby configured in its Preferences > Ruby > Interpreters: /Users/username/.rvm/rubies/ruby-2.1.0/bin/ruby

I knew the mail gem was installed for that ruby, outside of Eclipse:

$ gem which mail
/Users/username/.rvm/gems/ruby-2.1.0/gems/mail-2.6.3/lib/mail.rb

I tried @Don Kirkby's suggestion of adding -rubygems as an Interpreter argument in Debug Configurations, but it still wasn't working.

What DID get it working, oddly enough, was to add the GEM_HOME and GEM_PATH variables to the Environment section of the Debug Configurations.

I found the correct values (set by rvm, I presume) by echoing them in the terminal, outside of Eclipse:

$ echo $GEM_HOME
/Users/username/.rvm/gems/ruby-2.1.0
$ echo $GEM_PATH
/Users/username/.rvm/gems/ruby-2.1.0:/Users/username/.rvm/gems/ruby-2.1.0@global

Adding those two as environment variables in Debug Configurations > Environment tab did get debugging working in Eclipse, using the Ruby Built-In Debugger as the debug Engine in Preferences. Incidentally, I tried using 'Fast Ruby Debugger (ruby-debug)' engine, but got this error:

dyld: lazy symbol binding failed: Symbol not found: _rb_vm_get_sourceline
  Referenced from: /Users/username/.rvm/gems/ruby-2.1.0/extensions/x86_64-darwin-12/2.1.0-static/debugger-1.6.8/ruby_debug.bundle
  Expected in: flat namespace

dyld: Symbol not found: _rb_vm_get_sourceline
  Referenced from: /Users/username/.rvm/gems/ruby-2.1.0/extensions/x86_64-darwin-12/2.1.0-static/debugger-1.6.8/ruby_debug.bundle
  Expected in: flat namespace

Sidenote: Trying to hunt down a fix to the Symbol not found error for the Fast Ruby Debugger engine led me to this thread: Debugging in ruby 1.9 , which seems to imply that neither ruby-debug nor debugger gem is appropriate to use with ruby 2.0+, and instead recommended the byebug gem. But since I don't see a way to use byebug with Eclipse, I just ended up using the Ruby Built-In Debugger engine with the debugger and ruby-debug-ide gems:

$ gem install debugger
Successfully installed debugger-1.6.8
$ gem install ruby-debug-ide
Successfully installed ruby-debug-ide-0.4.26

which I got from this post: https://endocode.com/blog/2012/09/03/debugging-ruby-1-9-3-applications-in-eclipse/

Hopefully this is helpful to somebody who's trying to get Ruby 1.9/2.0+ debugging working with Eclipse.

这篇关于X-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆