nonsequitur / inf-ruby

218 stars 68 forks source link

How to load file in gems folder #116

Closed foreverqihe closed 4 years ago

foreverqihe commented 6 years ago

Hi, I am using robe mode to write Rake scripts (ruby files) My Gemfile has a gem on local path, e.g.:

gem “foo”, :path => “/path/to/foo”

My issue is the robe-start or inf-ruby cannot load the file as lib/main.rb has:

require 'foo'

How to solve this issue so I can jump to definition without having to use IntelliJ/RubyMine?

Thank you in advance.

Regards, He Qi

dgutov commented 6 years ago

Have you tried starting the REPL with M-x inf-ruby-console-auto?

foreverqihe commented 6 years ago

Hi @dgutov ,

Thank you for reply. Yes, I did. It blocked the whole emacs.

After I type M-x inf-ruby-console-auto, it starts the pry, and I just typed ENTER, the whole emacs is blocked. Not sure if it is my computer's issue. So I have to C-g and kill the buffer, then I turn to C-c C-s (Start REPL) and it starts irb, But it can't load my file in local gem: LoadError: cannot load such file -- foo/bar

Regards, He Qi

dgutov commented 6 years ago

That is the problem you'll need to solve, then. inf-ruby-console-auto is designed to create a REPL with your environment loaded.

As far as freezing goes, try M-x toggle-debug-on-quit, then, when it freezes, press C-g and see if the backtrace shows anything interesting.

foreverqihe commented 6 years ago

Followed your instruction, I got this. But I am not familiar with elisp. Anything interesting for you?

Debugger entered--Lisp error: (quit) accept-process-output(#) comint-send-input() funcall-interactively(comint-send-input)

(comint-send-input nil nil)

apply(# comint-send-input (nil nil)) call-interactively@ido-cr+-record-current-command(# comint-send-input nil nil) apply(call-interactively@ido-cr+-record-current-command # (comint-send-input nil nil)) call-interactively(comint-send-input nil nil) command-execute(comint-send-input)

dgutov commented 6 years ago

Oh, that's weird. It freezes while processing that Enter. Not sure I've seen that before.

What I can recommend, is edebug-ing comint-send-input:

First, launch the REPL with inf-ruby-console-auto, but don't press Enter afterwards, yet.

  1. M-x find-function RET comint-send-input RET.
  2. M-x edebug-defun RET (it should echo comint-send-input).

Then go back the REPL, press RET, and go though the function step-by-step, see if anything odd jumps out at you.

This is probably going to be a rabbit hole, though. The real answer might be along the lines of "recompile Ruby with readline support", or something similar.

Are you on MS-Windows? Maybe some other Windows users could help.

foreverqihe commented 6 years ago

will give it a go and let you know the result.

dgutov commented 4 years ago

@foreverqihe Let me know if there are any news.