rinari-console and comint-previous-input

229 views
Skip to first unread message

Duncan Mak

unread,
Jun 16, 2011, 11:57:14 AM6/16/11
to emacs-o...@googlegroups.com
I started using rinari-mode and I noticed in the *ruby* buffer from rinari-console, comint-previous-input fails (M-p) with this error:

inf-ruby-get-old-input: Search failed: "^>> "

I see that the regexp is explicitly written in the code - is there a reason for that? 

Is there a fix?

Thank you.

Duncan.

Aleksandar Simic

unread,
Jun 16, 2011, 12:21:53 PM6/16/11
to emacs-o...@googlegroups.com

Hello Duncan,

how are you using ruby interpreter ? Via RVM or just "native" (without RVM)?

I ask this since I've only seen this issue when using Ruby via RVM and
it has been annoying me, but I just didn't have time to poke it
further...

Aleksandar

Duncan Mak

unread,
Jun 17, 2011, 3:13:03 PM6/17/11
to emacs-o...@googlegroups.com
Yeah, I'm using RVM also - I found some rvm emacs package and that's what I'm using.

Steve Purcell

unread,
Jun 18, 2011, 4:47:38 AM6/18/11
to emacs-o...@googlegroups.com
I've committed what I think is a fix for this issue:

https://github.com/eschulte/rinari/commit/235f14b4c10312297cfaed29d45456ba361b2ddf

Please let me know if it doesn't work for you.

-Steve

Aleksandar Simic

unread,
Jun 18, 2011, 5:28:20 AM6/18/11
to emacs-o...@googlegroups.com

Thank you Steve, I'll have a look at it later today

Aleksandar Simic

unread,
Jun 18, 2011, 8:57:27 AM6/18/11
to emacs-o...@googlegroups.com
Hello Steve,

thanks again for providing this fix. However it doesn't work in some cases.

I've posted a gist here: https://gist.github.com/1033069 outlining a
solution for me and a slight tweak to the regexp.

It might be a good idea to get the inf-ruby/irb prompts for all the
versions of ruby, in order to have a catch all solution.

The only reason I posted the above as a gist and not in the comments
of your diff is because the comment text box at github was escaping
some of the regexp's escape characters...

Aleksandar

Steve Purcell

unread,
Jun 19, 2011, 9:16:29 AM6/19/11
to emacs-o...@googlegroups.com
Aleksandar Simic <asi...@gmail.com> writes:
> Hello Steve,
>
> thanks again for providing this fix. However it doesn't work in some cases.
>
> I've posted a gist here: https://gist.github.com/1033069 outlining a
> solution for me and a slight tweak to the regexp.
>
> It might be a good idea to get the inf-ruby/irb prompts for all the
> versions of ruby, in order to have a catch all solution.


Thanks! I've modified the regexp again so that it matches all of your
examples, but I've purposely kept it a little more conservative than
your proposed alternative. I think it should handle all the likely cases
now.

-Steve

Duncan Mak

unread,
Jun 21, 2011, 6:20:23 PM6/21/11
to emacs-o...@googlegroups.com
I'm trying to to run the latest checkout of rinari, and I keep on running into this error:

if: Wrong type argument: stringp, nil

Duncan.

Aleksandar Simic

unread,
Jun 21, 2011, 6:45:04 PM6/21/11
to emacs-o...@googlegroups.com

Hi Duncan,

What does your irb prompt look like (outside rinari, on a console)?

Can you run inf-ruby mode without issues?

Duncan Mak

unread,
Jun 21, 2011, 7:06:15 PM6/21/11
to emacs-o...@googlegroups.com
I think I'm crashing inside rinari-root.

My prompt looks like this: jruby-1.6.1 :001 > 

Duncan.

Aleksandar Simic

unread,
Jun 22, 2011, 2:56:38 AM6/22/11
to emacs-o...@googlegroups.com

Hello,

Can you do the following:

1. describe your whole session, from the start until the crash

2. Separately, run "M-x inf-ruby". Do you experience any issues?

Thanks

Steve Purcell

unread,
Jun 22, 2011, 3:26:27 AM6/22/11
to emacs-o...@googlegroups.com
Apologies if I've unwittingly broken things for you.

Please try "M-x toggle-debug-on-error" before triggering the error, then
post the traceback you get.

-Steve

Duncan Mak

unread,
Jul 22, 2011, 6:06:09 PM7/22/11
to emacs-o...@googlegroups.com
Sorry it took me so long to reply:

Here's the stack trace that I get:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("\\(^[[:alpha:]]:/$\\|^/[^/]+:/?$\\|^/$\\)" nil)
  (if (string-match "\\(^[[:alpha:]]:/$\\|^/[^/]+:/?$\\|^/$\\)" dir) nil (rinari-root new-dir))
  (unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^/]+:/?$\\|^/$\\)" dir) (rinari-root new-dir))
  (let ((new-dir (expand-file-name (file-name-as-directory "..") dir))) (unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^/]+:/?$\\|^/$\\)" dir) (rinari-root new-dir)))
  (if (file-exists-p (expand-file-name "environment.rb" (expand-file-name "config" dir))) dir (let ((new-dir (expand-file-name (file-name-as-directory "..") dir))) (unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^/]+:/?$\\|^/$\\)" dir) (rinari-root new-dir))))
  rinari-root()
  (expand-file-name "script" (rinari-root))
  (file-name-as-directory (expand-file-name "script" (rinari-root)))
  (concat (file-name-as-directory (expand-file-name "script" (rinari-root))))
  rinari-script-path()
  (let* ((default-directory (rinari-root)) (script (rinari-script-path)) (command (expand-file-name (if (file-exists-p (expand-file-name "console" script)) "console" "rails console") script))) (if rinari-rails-env (setq command (concat command " " rinari-rails-env))) (setq command (if edit-cmd-args (read-string "Run Ruby: " (concat command " ")) command)) (run-ruby command) (save-excursion (set-buffer "*ruby*") (set (make-local-variable (quote inf-ruby-prompt-pattern)) "^\\(j?ruby[^> ]+\\|J?RUBY[^> ]+\\|irb([^> ]+\\)?\\( ?:[0-9]+\\)* ?>>? ") (set (make-local-variable (quote inf-ruby-first-prompt-pattern)) inf-ruby-prompt-pattern) (rinari-launch)))
  rinari-console(nil)
  call-interactively(rinari-console t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)

Steve Purcell

unread,
Jul 25, 2011, 4:49:18 AM7/25/11
to emacs-o...@googlegroups.com
Are you perhaps executing rinari-console while in a buffer that has no
associated file, e.g. *scratch*? It looks like rinari-root is seeing a nil
value for 'default-directory.

Do things work if you open a file inside your rails project, and execute
rinari-console while your cursor is in the buffer for that file?

-Steve

Duncan Mak

unread,
Jul 25, 2011, 11:19:49 AM7/25/11
to emacs-o...@googlegroups.com
I was running it in the dired buffer of the directory that contains my project. I also tried running rinari-console when the buffer is open on a Rakefile in the project.

I'm running Emacs 24 now, but when I first encountered this problem, I was running Emacs23. 

From describe-variable:
default-directory is a variable defined in `C source code'.
Its value is "/home/duncan/git/Scraper-Node/"
Local in buffer Rakefile; global value is nil
  Automatically becomes buffer-local when set in any fashion.
  This variable is safe as a file local variable if its value
  satisfies the predicate `stringp'.
Documentation:
Name of default directory of current buffer.  Should end with slash.
To interactively change the default directory, use command `cd'.
Duncan. 

Steve Purcell

unread,
Jul 26, 2011, 5:44:21 AM7/26/11
to emacs-o...@googlegroups.com
I've filed this as an issue here so I don't forget, but I'm a bit snowed
under, so may not be able to address it immediately:

https://github.com/eschulte/rinari/issues/8

-Steve

Duncan Mak

unread,
Aug 2, 2011, 8:10:23 PM8/2/11
to emacs-o...@googlegroups.com
I'm really surprised that I'm the only look experiencing this problem.

I must have something configured wrong?

Duncan.

Steve Purcell

unread,
Aug 3, 2011, 2:54:27 AM8/3/11
to emacs-o...@googlegroups.com
I've been coming to the same conclusion. If you could show how to
reproduce the error from a clean Emacs, I'd have somewhere to start.

-Steve

Duncan Mak

unread,
Aug 19, 2011, 2:23:56 PM8/19/11
to emacs-o...@googlegroups.com
So what's the best way to run rinari-console?

Normally, I open up a dired buffer on the folder with "script/console" and then I run M-x rinari-console from there.

Is that not the right way to start the console?

Duncan.

Steve Purcell

unread,
Aug 19, 2011, 2:29:11 PM8/19/11
to emacs-o...@googlegroups.com
Aha! No, "M-x rinari-console" will actually run "script/console" (or "rails console") for you.

-Steve

Duncan Mak

unread,
Aug 19, 2011, 2:55:51 PM8/19/11
to emacs-o...@googlegroups.com
So in which buffer do you run rinari-console?

Steve Purcell

unread,
Aug 19, 2011, 3:26:04 PM8/19/11
to emacs-o...@googlegroups.com
Duncan Mak <dunc...@gmail.com> writes:
> So in which buffer do you run rinari-console?


Any buffer in which 'rinari-launch has been called, I think. So normally you'd
have something like this:

(add-hook 'ruby-mode-hook 'rinari-launch)

and then in any ruby buffer inside a Rails source tree, rinari-console
should do the right things.

-Steve

Duncan Mak

unread,
Aug 19, 2011, 3:41:11 PM8/19/11
to emacs-o...@googlegroups.com
Aha - the project that I'm working is not actually a rails project, but it does have a script/console file.

Once I made a dummy config/environment.rb file, rinari-console started to work.

New problem: 

LoadError: no such file to load -- bundler
       require at org/jruby/RubyKernel.java:1038
       require at /home/duncan/.rvm/rubies/jruby-1.6.3/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29

Duncan.

Duncan Mak

unread,
Aug 19, 2011, 3:46:47 PM8/19/11
to emacs-o...@googlegroups.com
Woohoo - I ran M-x use-rvm and I'm cooking with gas!

It'd be nice if that can be run automatically, but that's a problem for a different Google Group.

Thanks for all the help!

Duncan.

Steve Purcell

unread,
Aug 19, 2011, 3:56:07 PM8/19/11
to emacs-o...@googlegroups.com
Happy you got things working!

-Steve

Reply all
Reply to author
Forward
0 new messages