-
Notifications
You must be signed in to change notification settings - Fork 103
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
IEx: No secondary prompt, hang after multiline input #56
Comments
Hey @andreas-roehler -- I just tried your example in the IEx prompt started by |
Sorry -- scratch what I said. What command are you using for newlines? I found that I was actually using |
So do I, after "end" RET, which does comint-send-input. Still hangs... |
BTW: it's the only example bug shows up - commonly iex works well from alchemist. |
@andreas-roehler thanks for reporting, this looks really like a bug and I'll try to find the issue. Thanks @jtmoulia for helping ❤️ |
I did some investigating and somehow comint and IEx don't get along. Here's the minimal test case: (apply 'make-comint "IEX"
"/usr/local/bin/iex" nil nil) got to IEX buffer and paste """
foo
""" and IEX appears to hang. Erl works fine. (apply 'make-comint "ERL"
"/usr/bin/erl" nil nil) and paste """
foo
"""
. I was wondering if it was something about the prompt. To rule it out I setup .iex.exs IEx.configure(alive_prompt: "%counter>", default_prompt: "%counter>",) This makes IEx prompt the same as erl's default prompt. Still hangs with multiline input. |
The problem may be in IEx itself. iex | cat paste a multi-line expression, get a hang |
Jose confirms problem in IEx: |
Thanks a lot guys for all the effort you put into hunting the issue. My apology for respond a but late, but all these holidays and my kids were ill too made my days a bit busy. :-) I have kind of an idea to fix this issue, I'll get back to you if I have a branch for testing ready. |
@tonini What's the idea? Tell us more :-) Still waiting for a reply from Jose on what's the underlying problem with IEx. Meanwhile I hacked together an IEx wrapper script that seems to workaround the problem. The idea is to always wait for a prompt (maybe secondary prompt) before sending another line of input. Seems to work, even if there are potential corner case correctness issues. Edit: cleaned up the script #!/usr/bin/env ruby
# based on http://stackoverflow.com/questions/2730642/wrapper-around-bash-control-stdin-and-stdout
require 'pty'
require 'thread'
mutex = Mutex.new
saw_prompt = ConditionVariable.new
system('stty -echo') if ENV['Emacs']
PTY.spawn("/usr/local/bin/iex") do |p_read, p_write|
Thread.new do
loop do
mutex.synchronize {
saw_prompt.wait(mutex)
input = STDIN.gets
# puts "== read from STDIN: #{input}"
# STDOUT.flush
p_write.print input
# puts "== wrote to process: #{input}"
}
end
end
loop do
output = p_read.sysread(512)
# puts "== read from process: #{output}"
print output
# puts "wrote to STDOUT: #{output}"
STDOUT.flush
saw_prompt.signal if output.include?("iex(") || output.include?("...(")
end
end |
@gleb If the underlaying problem could be fixed Elixir wise that would be great! On the other hand I realized that there is an issue that we have to wait until the I will push the branch soon so you guys could test it. |
@gleb @andreas-roehler is fixed on master |
@tonini Works for me. Thanks! Will use/test it more, and let you know if anything comes up. |
Can't put in a form like:
if true do
"asdf"
end
IEx hangs, resp. echos the input, but not the expected result.
Whilst when iex is called from bash, "asdf" appears as expected.
Thanks!
The text was updated successfully, but these errors were encountered: