Closed aaronjensen closed 4 years ago
I suspect this is rather the same as https://github.com/nonsequitur/inf-ruby/pull/127
Better, rbenv-aware patches welcome.
Hm, interesting. Yes, that seems possible, though this fix doesn't work for me because it's running bundle console
. I did notice that both irb versions have an --inf-ruby-mode
flag. Perhaps that could be used universally?
It doesn't solve the bundle console problem, however. Is there a way to force inf-ruby to use straight irb?
Sure: you call M-x inf-ruby
. But that will rid you of the benefits inf-ruby-console
was designed to provide.
I did notice that both irb versions have an --inf-ruby-mode flag. Perhaps that could be used universally?
Please go ahead and test it. Does it make M-x inf-ruby
work with Ruby 2.7?
It does not work. I still get the ▽
prompt. --legacy
does not work either.
Even on ruby 2.5.5
, inf-ruby
does not appear to work for me. inf-ruby-console-default
does, however.
IRB 1.1.0 is what I have with ruby 2.5.5, and when running it, it prints:
This version of IRB is drastically different from the previous version.
If you hit any issues, you can use "irb --legacy" to run the old version.
If you want to just erase this message, please use "irb --multiline".
I'm quite confused...
A few things:
The version of IRB (0.9.6) included with Ruby 2.5.7 (I just installed) doesn't have this problem. But you can install a newer IRB from Rubygems, and it indeed exhibits this behavior.
I'm guessing --legacy
is feature of IRB that is built-in in 2.7. The standalone version has --nomultiline
, however.
Also see https://github.com/ruby/irb/issues/68.
Okay, that worked, thank you. How might one fix this for auto/bundle console? (which is apparently deprecated now...)
Just call M-x inf-ruby-console-auto
. Or M-x inf-ruby-console-script
if you insist on skipping the automatic dispatch.
Unfortunately, that doesn't use inf-ruby-implementations
, it has the flags hard coded, so that requires a patch, it looks like.
bin/console
?
I didn't have a bin/console in this project. It ended up using inf-ruby-console-gem
I think the original deprecation message said you should generate it with bundle gem ...
?
Or maybe generate it in a test project and then copy it over.
Even if I do that, the bin/console script invokes irb without arguments, which means that it has the same multiline issue. I could replace bin/console with something that ran irb with the appropriate arguments, but then I'd need to do that for every project and it seems like a bit of a hack since the idea of using bin/console, I'm guessing, is to have a sort of zero-config, "it just works" option.
could replace bin/console with something that ran irb with the appropriate arguments, but then I'd need to do that for every project and it seems like a bit of a hack since the idea of using bin/console, I'm guessing, is to have a sort of zero-config, "it just works" option.
I agree that it seems suboptimal, but it seems like the officially recommended option.
Unless IRB can read the necessary arguments from environment variables...
I don't know if it's possible to handle new irb prompt in Emacs (it seems it emits escape sequences that maybe could be handled), but I solved the problem of broken prompt of bundle console by adding to ~/.irbrc
this line IRB.conf[:USE_SINGLELINE] = true
(this is equivalent to using the --legacy
switch). Also tried IRB.conf[:PROMPT_MODE] = :INF_RUBY
(equivalent to --inf-ruby-mode
), but it's still broken.
@link0ff Thanks for the workaround. I've pushed a user-friendlier fix now.
So... that fix should help the M-x inf-ruby
case, but not inf-ruby-console-gem
.
@aaronjensen Could you test this additional patch?
diff --git a/inf-ruby.el b/inf-ruby.el
index f93164f..8a21039 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -102,12 +102,16 @@ returns a string."
:group 'inf-ruby)
(defun inf-ruby--irb-command ()
- (let ((command "irb --prompt default --noreadline -r irb/completion")
- (version (nth 1 (split-string (shell-command-to-string "irb -v") "[ (]"))))
- (when (version<= "1.2.0" version)
+ (let ((command "irb --prompt default --noreadline -r irb/completion"))
+ (when (inf-ruby--irb-needs-nomultiline-p)
(setq command (concat command " --nomultiline")))
command))
+(defun inf-ruby--irb-needs-nomultiline-p ()
+ (let ((version (nth 1 (split-string
+ (shell-command-to-string "irb -v") "[ (]"))))
+ (version<= "1.2.0" version)))
+
(defcustom inf-ruby-console-environment 'ask
"Envronment to use for the `inf-ruby-console-*' commands.
If the value is not a string, ask the user to choose from the
@@ -929,6 +933,8 @@ Gemfile, it should use the `gemspec' instruction."
(concat " -r " (file-name-sans-extension file)))
files
""))))
+ (when (inf-ruby--irb-needs-nomultiline-p)
+ (setq base-command (concat base-command " --nomultiline")))
(inf-ruby-console-run
(concat base-command args
" --prompt default --noreadline -r irb/completion")
@dgutov it seems to work for me with ruby 2.7. As far as I can tell, it did not require the main gem entry point--is it supposed to do that?
it seems to work for me with ruby 2.7.
Thanks for verifying.
As far as I can tell, it did not require the main gem entry point--is it supposed to do that?
Does the current version do that? If not, it seems like a separate issue. Though maybe your entry point doesn't adhere to the naming conventions.
Though maybe your entry point doesn't adhere to the naming conventions.
This is the case. The name of the gem includes an extra prefix, but it doesn't match the directory structure.
OK, then it's orthogonal, at least. I'm gonna push the fix now.
I don't know where to mention this, but in Ruby 3.1 using the bundled debugger has the same problem that it displays the triangle character and hangs the comint buffer. A workaround is to use the env.variable RUBY_DEBUG_NO_RELINE
.
@link0ff A new report is probably a better place (or a PR). I haven't used the bundled myself yet.
It sounds like a new entry in the Bugs section of the Readme, at least. Though unlike .irbrc
, at least, there won't be a single file to put that env var setting, right?
A new report is in #158. I don't know if a single file is possible to put that env.var setting.
When running
inf-ruby-console-default
in a project that works with Ruby 2.5.5, I see this:If I type after the
▽
and press enter, nothing happens. If I switch to Ruby 2.5.5, this all works as expected.