Setting up gems in eclipse

I am trying to work on a tramp / chef project in eclipse. I am new to both technologies and a little rusty with ruby. I installed rdt and have a ruby ​​project with code.

However, the eclipse does not seem to realize that gems are required. Is there a way to get ruby ​​gems and an eclipse to play well together. I thought I could add gems as libraries, but this does not seem to work.

+6
source share
4 answers

I had a very similar problem - getting Eclipse to recognize my installed gems. I used rvm , pointing to ruby ​​2.1.0 by default. The ruby ​​code I was debugging had one require 'mail' at the top. When launching or debugging a script, an error was displayed on the console:

 /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 settings> Ruby> Interpreters: /Users/username/.rvm/rubies/ruby-2.1.0/bin/ruby

I knew that a mail stone outside of Eclipse was installed for this ruby:

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

I tried @Don Kirkby to suggest adding -rubygems as an Interpreter argument in Debug Configurations, but it still didn't work.

What DID got this, oddly enough, was to add the GEM_HOME and GEM_PATH to the "Environment" section of Debug configurations.

I found the correct values ​​(given by rvm, I suppose), 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 these two environment variables to “Debug Configurations”> the “Environment” tab got debugging that works in Eclipse using the Ruby Built-In Debugger as Engine in Preferences debugger. By the way, I tried using "Fast Ruby Debugger (ruby-debug)", 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: an attempt to find a fix for the Symbol not found error for the fast Ruby Debugger mechanism led me to this topic: Debugging in ruby ​​1.9 , which seems like neither ruby-debug nor debugger gem is suitable for use with ruby ​​2.0+ and recommends byebug gem instead. But since I see no way to use byebug with Eclipse, I just finished using the Ruby Built-In Debugger engine with 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/

Hope this helps someone trying to debug Ruby 1.9 / 2.0 + while working with Eclipse.

+2
source

I'm not sure about the exact order in which eclipse is configured, but you can check out Aptana Studio . I used it a while ago when it was known as RadRails, and that was great. This is an eclipse-based environment that works with Ruby and Ruby on rails out of the box.

0
source

Try using rvm ( https://rvm.io/ ) and gemsets to manage the ruby ​​and precious stones needed for this project. There is already an answer from stackoverflower: fooobar.com/questions/891202 / ... , which covers getting your eclipse project to recognize rvm parameters via a .rvmrc file.

0
source

From the Eclipse Window menu, select Preferences. Go to Ruby: Translators. Modify the interpreter and set the interpreter arguments to -rubygems . This made my installation see the ruby ​​gems that I installed.

To check which stones you have installed, use this command in the terminal:

 gem query --local 
0
source

Source: https://habr.com/ru/post/891201/


All Articles