Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with latest IRB #128

Closed
aaronjensen opened this issue Jan 23, 2020 · 23 comments
Closed

Incompatible with latest IRB #128

aaronjensen opened this issue Jan 23, 2020 · 23 comments

Comments

@aaronjensen
Copy link

When running inf-ruby-console-default in a project that works with Ruby 2.5.5, I see this:

[DEPRECATED] bundle console will be replaced by `bin/console` generated by `bundle gem <name>`
▽

If I type after the and press enter, nothing happens. If I switch to Ruby 2.5.5, this all works as expected.

@dgutov
Copy link
Collaborator

dgutov commented Jan 23, 2020

I suspect this is rather the same as #127

Better, rbenv-aware patches welcome.

@aaronjensen
Copy link
Author

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?

@dgutov
Copy link
Collaborator

dgutov commented Jan 26, 2020

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?

@aaronjensen
Copy link
Author

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...

@dgutov
Copy link
Collaborator

dgutov commented Jan 27, 2020

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 ruby/irb#68.

@dgutov dgutov changed the title Incompatible with Ruby 2.7.0 (or maybe Bundler 2?) Incompatible with latest IRB Jan 27, 2020
@aaronjensen
Copy link
Author

Okay, that worked, thank you. How might one fix this for auto/bundle console? (which is apparently deprecated now...)

@dgutov
Copy link
Collaborator

dgutov commented Jan 27, 2020

Just call M-x inf-ruby-console-auto. Or M-x inf-ruby-console-script if you insist on skipping the automatic dispatch.

@aaronjensen
Copy link
Author

Unfortunately, that doesn't use inf-ruby-implementations, it has the flags hard coded, so that requires a patch, it looks like.

@dgutov
Copy link
Collaborator

dgutov commented Jan 27, 2020

bin/console?

@aaronjensen
Copy link
Author

I didn't have a bin/console in this project. It ended up using inf-ruby-console-gem

@dgutov
Copy link
Collaborator

dgutov commented Jan 27, 2020

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.

@aaronjensen
Copy link
Author

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.

@dgutov
Copy link
Collaborator

dgutov commented Jan 28, 2020

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...

@link0ff
Copy link

link0ff commented Feb 28, 2020

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.

@dgutov
Copy link
Collaborator

dgutov commented Mar 1, 2020

@link0ff Thanks for the workaround. I've pushed a user-friendlier fix now.

@dgutov
Copy link
Collaborator

dgutov commented Mar 1, 2020

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 dgutov reopened this Mar 1, 2020
@aaronjensen
Copy link
Author

@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?

@dgutov
Copy link
Collaborator

dgutov commented Mar 3, 2020

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.

@aaronjensen
Copy link
Author

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.

@dgutov
Copy link
Collaborator

dgutov commented Mar 3, 2020

OK, then it's orthogonal, at least. I'm gonna push the fix now.

@link0ff
Copy link

link0ff commented Jan 17, 2022

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.

@dgutov
Copy link
Collaborator

dgutov commented Jan 17, 2022

@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?

@link0ff
Copy link

link0ff commented Jan 18, 2022

A new report is in #158. I don't know if a single file is possible to put that env.var setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants