elixir icon indicating copy to clipboard operation
elixir copied to clipboard

Issue of rendering newline/line-warp on the terminal after running iex -S mix in the specific project

Open stevencch99 opened this issue 4 years ago • 4 comments

Elixir and Erlang/OTP versions

Erlang/OTP 25 [erts-13.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Elixir 1.14.0 (compiled with Erlang/OTP 25)

Operating system

MacBook Pro 2019, macOS Monterey v12.6

Current behavior

The terminal rendering became weird every time I ran $ iex -S mix in one of my working projects, it displays newline from the position of the end of last line, meanwhile the input becomes invisible.

I don’t know how to fix that terminal session, all I can do is open a new one.

This issue only occurred in the specific project, not in any other projects, below are the steps of how do we reproduce the issue, and all my colleagues can reproduce this issue too.

Does anyone know if there’s anything I can do? Please help, thanks.

Reproducing in the macOS built-in Terminal v2.12.7 and Bash v3.2.57

  1. Execute ls before $ iex -S mix, everything seems normal
  2. Run $ iex -S mix in the root directory of my project
  3. Abort iex with ctrl + \ and the terminal rendering become weird
  4. Execute ls after $ iex -S mix, the input command becomes invisible…

Reproducing in the iTerm2 v3.4.16 and Zsh v5.8

Expected behavior

The behavior of terminal rendering should be the same as before running iex -S mix.

stevencch99 avatar Oct 05 '22 02:10 stevencch99

Thank you for the report.

Unfortunately I cannot reproduce it. My suspicion is that your project or a dependency is mangling with the stdio file descriptors. Here are some options:

  1. Change your application.ex to start no children: Supervisor.start_link([], strategy: :one_for_one). If the issue is fixed, add the children back one by one to figure the culprit.

  2. If the issue is not fixed, then it is most likely a dependency. Create a new project, copy the deps from your mix.exs, and see if you can reproduce it. If not, copy the mix.lock from your project and see if it reproduces it.

josevalim avatar Oct 05 '22 08:10 josevalim

The issue was fixed by removing the elixir-nodejs server from the children list in application.ex, now we have a starting point to figure out what to do next.

Thank you so much! @josevalim

stevencch99 avatar Oct 05 '22 11:10 stevencch99

Perfect, I will close this since I don't believe to be an Elixir issue. The project may be using fd0/fd1 for communication with Node, instead of redirecting to other descriptors. So maybe worth investigating.

josevalim avatar Oct 05 '22 12:10 josevalim

Hi @josevalim,

don't mean to re-open this as I agree it's not an elixir issue, but I opened an issue on the nodejs lib about this and thought maybe you could have new ideas of how to address this given the few findings I made while debugging this ?

I am fairly new to elixir so I had some trouble debugging the node.js output when using iEX but still found some interesting things: https://github.com/revelrylabs/elixir-nodejs/issues/90

if you have an idea how we can make sure we sanitize correctly the escape characters sent by node, that might help us fix the problem

francois-codes avatar Nov 23 '24 08:11 francois-codes